This commit is contained in:
syuilo 2018-04-13 12:05:24 +09:00
parent f3c4152a68
commit b099ad2a30
4 changed files with 18 additions and 10 deletions

View File

@ -45,7 +45,7 @@ export default Vue.extend({
} else if (url.hostname == 'youtu.be') { } else if (url.hostname == 'youtu.be') {
this.youtubeId = url.pathname; this.youtubeId = url.pathname;
} else { } else {
fetch('/api:url?url=' + this.url).then(res => { fetch('/url?url=' + this.url).then(res => {
res.json().then(info => { res.json().then(info => {
this.title = info.title; this.title = info.title;
this.description = info.description; this.description = info.description;

View File

@ -6,7 +6,7 @@ html(lang= lang)
meta(name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no") meta(name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no")
title title
| #{title} | Misskey Docs | #{title} | Misskey Docs
link(rel="stylesheet" href="/assets/style.css") link(rel="stylesheet" href="/docs/assets/style.css")
block meta block meta
//- FontAwesome style //- FontAwesome style

View File

@ -2,20 +2,26 @@
* Docs * Docs
*/ */
import * as path from 'path'; import ms = require('ms');
import * as Router from 'koa-router'; import * as Router from 'koa-router';
import * as send from 'koa-send'; import * as send from 'koa-send';
const docs = path.resolve(`${__dirname}/../../client/docs/`); const docs = `${__dirname}/../../client/docs/`;
const router = new Router(); const router = new Router();
router.get('/assets', async ctx => { router.get('/assets/*', async ctx => {
await send(ctx, `${docs}/assets`); await send(ctx, ctx.path, {
root: docs,
maxage: ms('7 days'),
immutable: true
});
}); });
router.get(/^\/([a-z_\-\/]+?)$/, async ctx => { router.get('*', async ctx => {
await send(ctx, `${docs}/${ctx.params[0]}.html`); await send(ctx, `${ctx.params[0]}.html`, {
root: docs
});
}); });
module.exports = router; export default router;

View File

@ -8,6 +8,8 @@ import * as Router from 'koa-router';
import * as send from 'koa-send'; import * as send from 'koa-send';
import * as favicon from 'koa-favicon'; import * as favicon from 'koa-favicon';
import docs from './docs';
const client = `${__dirname}/../../client/`; const client = `${__dirname}/../../client/`;
// Init app // Init app
@ -54,7 +56,7 @@ router.get('/manifest.json', async ctx => {
//#endregion //#endregion
// Docs // Docs
router.use('/docs', require('./docs').routes()); router.use('/docs', docs.routes());
// URL preview endpoint // URL preview endpoint
router.get('url', require('./url-preview')); router.get('url', require('./url-preview'));