OGP向けにインスタンスのバナー画像を提供するように
This commit is contained in:
@ -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
|
||||
|
44
src/server/web/views/base.pug
Normal file
44
src/server/web/views/base.pug
Normal file
@ -0,0 +1,44 @@
|
||||
block vars
|
||||
|
||||
doctype html
|
||||
|
||||
!= '\n<!-- Thank you for using Misskey! @syuilo -->\n'
|
||||
|
||||
html
|
||||
|
||||
head
|
||||
meta(charset='utf-8')
|
||||
meta(name='application-name' content='Misskey')
|
||||
meta(name='referrer' content='origin')
|
||||
meta(property='og:site_name' content='Misskey')
|
||||
link(rel='manifest' href='/manifest.json')
|
||||
|
||||
title
|
||||
block title
|
||||
| Misskey
|
||||
|
||||
block desc
|
||||
meta(name='description' content='A planet of fediverse')
|
||||
|
||||
block meta
|
||||
|
||||
block og
|
||||
meta(property='og:image' content=img)
|
||||
|
||||
style
|
||||
include ./../../../../built/client/assets/init.css
|
||||
script
|
||||
include ./../../../../built/client/assets/boot.js
|
||||
|
||||
script
|
||||
include ./../../../../built/client/assets/safe.js
|
||||
|
||||
body
|
||||
noscript: p
|
||||
| JavaScriptを有効にしてください
|
||||
br
|
||||
| Please turn on your JavaScript
|
||||
div#ini.
|
||||
<svg viewBox="0 0 50 50">
|
||||
<path fill=#fb4e4e d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" />
|
||||
</svg>
|
@ -1,4 +1,4 @@
|
||||
extends ../../../../src/client/app/base
|
||||
extends ./base
|
||||
|
||||
block vars
|
||||
- const user = note.user;
|
||||
@ -11,14 +11,16 @@ block title
|
||||
block desc
|
||||
meta(name='description' content= summary)
|
||||
|
||||
block meta
|
||||
meta(name='twitter:card' content='summary')
|
||||
block og
|
||||
meta(property='og:type' content='article')
|
||||
meta(property='og:title' content= title)
|
||||
meta(property='og:description' content= summary)
|
||||
meta(property='og:url' content= url)
|
||||
meta(property='og:image' content= user.avatarUrl)
|
||||
|
||||
block meta
|
||||
meta(name='twitter:card' content='summary')
|
||||
|
||||
if note.prev
|
||||
link(rel='prev' href=`${config.url}/notes/${note.prev}`)
|
||||
if note.next
|
||||
|
@ -1,4 +1,4 @@
|
||||
extends ../../../../src/client/app/base
|
||||
extends ./base
|
||||
|
||||
block vars
|
||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
||||
@ -11,14 +11,16 @@ block title
|
||||
block desc
|
||||
meta(name='description' content= user.description)
|
||||
|
||||
block meta
|
||||
meta(name='twitter:card' content='summary')
|
||||
block og
|
||||
meta(property='og:type' content='blog')
|
||||
meta(property='og:title' content= title)
|
||||
meta(property='og:description' content= user.description)
|
||||
meta(property='og:url' content= url)
|
||||
meta(property='og:image' content= img)
|
||||
|
||||
|
||||
block meta
|
||||
meta(name='twitter:card' content='summary')
|
||||
|
||||
if !user.host
|
||||
link(rel='alternate' href=`${config.url}/users/${user._id}` type='application/activity+json')
|
||||
if user.uri
|
||||
|
Reference in New Issue
Block a user