1
0
mirror of https://github.com/byulmaru/quesdon synced 2024-11-30 15:58:01 +09:00

haed에 rel="me"와 프로필 주소가 포함된 link 태그 추가

This commit is contained in:
liberaldev 2023-08-01 00:55:21 +09:00
parent c89e4ce158
commit d73a2db8ed
2 changed files with 12 additions and 1 deletions

View File

@ -26,7 +26,8 @@ router.use('/api', apiRouter.routes());
router.get('/*', async (ctx: Koa.ParameterizedContext) =>
{
let user;
let user, mastodonUrl;
const path = ctx.request.path.toString();
if (ctx.session.user)
{
user = await User.findById(ctx.session.user);
@ -34,11 +35,19 @@ router.get('/*', async (ctx: Koa.ParameterizedContext) =>
user = new Buffer(user, 'binary').toString('base64');
}
if (!ctx.session.csrfToken)
{
ctx.session.csrfToken = rndstr();
}
if (path.match(/@/g)?.length as number === 2)
{
const profile = await User.findOne({acctLower: path.substring(2).toLowerCase()});
mastodonUrl = profile?.url;
}
return ctx.render('index',
{
GIT_COMMIT,
user,
mastodonUrl,
csrfToken: ctx.session.csrfToken
});
});

View File

@ -8,6 +8,8 @@ html
script window.USER=undefined
script window.CSRF_TOKEN="#{csrfToken}"
script window.GIT_VERSION="#{GIT_COMMIT}"
if mastodonUrl
link(rel="me",href=mastodonUrl)
script(src="https://cdn.polyfill.io/v2/polyfill.js?features=fetch")
script(src="/assets/bundle.js?version="+GIT_COMMIT)
body