Channel (#6621)
* wip * wip * wip * wip * wip * wip * wip * wip * wop * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * add notes * wip * wip * wip * wip * sound * wip * add kick_gaba2 * wip
This commit is contained in:
@@ -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 } from '../../models';
|
||||
import { Users, Notes, Emojis, UserProfiles, Pages, Channels } from '../../models';
|
||||
import parseAcct from '../../misc/acct/parse';
|
||||
import getNoteSummary from '../../misc/get-note-summary';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
@@ -188,7 +188,7 @@ router.get('/@:user.json', async ctx => {
|
||||
}
|
||||
});
|
||||
|
||||
//#region for crawlers
|
||||
//#region SSR (for crawlers)
|
||||
// User
|
||||
router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
|
||||
const { username, host } = parseAcct(ctx.params.user);
|
||||
@@ -297,6 +297,28 @@ router.get('/@:user/pages/:page', async ctx => {
|
||||
|
||||
ctx.status = 404;
|
||||
});
|
||||
|
||||
// Channel
|
||||
router.get('/channels/:channel', async ctx => {
|
||||
const channel = await Channels.findOne({
|
||||
id: ctx.params.channel,
|
||||
});
|
||||
|
||||
if (channel) {
|
||||
const _channel = await Channels.pack(channel);
|
||||
const meta = await fetchMeta();
|
||||
await ctx.render('channel', {
|
||||
channel: _channel,
|
||||
instanceName: meta.name || 'Misskey'
|
||||
});
|
||||
|
||||
ctx.set('Cache-Control', 'public, max-age=180');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.status = 404;
|
||||
});
|
||||
//#endregion
|
||||
|
||||
router.get('/info', async ctx => {
|
||||
|
21
src/server/web/views/channel.pug
Normal file
21
src/server/web/views/channel.pug
Normal file
@@ -0,0 +1,21 @@
|
||||
extends ./base
|
||||
|
||||
block vars
|
||||
- const title = channel.name;
|
||||
- const url = `${config.url}/channels/${channel.id}`;
|
||||
|
||||
block title
|
||||
= `${title} | ${instanceName}`
|
||||
|
||||
block desc
|
||||
meta(name='description' content= channel.description)
|
||||
|
||||
block og
|
||||
meta(property='og:type' content='article')
|
||||
meta(property='og:title' content= title)
|
||||
meta(property='og:description' content= channel.description)
|
||||
meta(property='og:url' content= url)
|
||||
meta(property='og:image' content= channel.bannerUrl)
|
||||
|
||||
block meta
|
||||
meta(name='twitter:card' content='summary')
|
Reference in New Issue
Block a user