クリップのOGP対応

This commit is contained in:
syuilo
2020-11-15 17:40:49 +09:00
parent d0c0104546
commit ccd14e0462
2 changed files with 53 additions and 1 deletions

View File

@@ -17,7 +17,7 @@ import packFeed from './feed';
import { fetchMeta } from '../../misc/fetch-meta';
import { genOpenapiSpec } from '../api/openapi/gen-spec';
import config from '../../config';
import { Users, Notes, Emojis, UserProfiles, Pages, Channels } from '../../models';
import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips } from '../../models';
import parseAcct from '../../misc/acct/parse';
import getNoteSummary from '../../misc/get-note-summary';
import { ensure } from '../../prelude/ensure';
@@ -298,6 +298,28 @@ router.get('/@:user/pages/:page', async ctx => {
ctx.status = 404;
});
// Clip
router.get('/clips/:clip', async ctx => {
const clip = await Clips.findOne({
id: ctx.params.clip,
});
if (clip) {
const _clip = await Clips.pack(clip);
const meta = await fetchMeta();
await ctx.render('clip', {
clip: _clip,
instanceName: meta.name || 'Misskey'
});
ctx.set('Cache-Control', 'public, max-age=180');
return;
}
ctx.status = 404;
});
// Channel
router.get('/channels/:channel', async ctx => {
const channel = await Channels.findOne({