OGP向けにインスタンスのバナー画像を提供するように

This commit is contained in:
syuilo
2018-12-15 23:19:04 +09:00
parent 9ab34c2301
commit be1125dcb9
10 changed files with 28 additions and 82 deletions

View File

@ -15,7 +15,7 @@ import parseAcct from '../../misc/acct/parse';
import config from '../../config';
import Note, { pack as packNote } from '../../models/note';
import getNoteSummary from '../../misc/get-note-summary';
const consts = require('../../const.json');
import fetchMeta from '../../misc/fetch-meta';
const client = `${__dirname}/../../client/`;
@ -26,8 +26,7 @@ const app = new Koa();
app.use(views(__dirname + '/views', {
extension: 'pug',
options: {
config,
themeColor: consts.themeColor
config
}
}));
@ -120,10 +119,11 @@ router.get('/notes/:note', async ctx => {
// Render base html for all requests
router.get('*', async ctx => {
await send(ctx, `app/base.html`, {
root: client,
maxage: ms('5m')
const meta = await fetchMeta();
await ctx.render('base', {
img: meta.bannerUrl
});
ctx.set('Cache-Control', 'public, max-age=86400');
});
// Register router