Skip to content

Commit

Permalink
chore: base.pug内でフラグでコントロールするように
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed May 21, 2024
1 parent 6d674ef commit 86dd815
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
19 changes: 4 additions & 15 deletions packages/backend/src/server/web/ClientServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ export class ClientServerService {

//#endregion

const renderBase = async (reply: FastifyReply) => {
const renderBase = async (reply: FastifyReply, data: { [key: string]: any } = {}) => {
const meta = await this.metaService.fetch();
reply.header('Cache-Control', 'public, max-age=30');
return await reply.view('base', {
Expand All @@ -447,6 +447,7 @@ export class ClientServerService {
title: meta.name ?? 'Misskey',
desc: meta.description,
...await this.generateCommonPugData(meta),
...data,
});
};

Expand Down Expand Up @@ -745,26 +746,14 @@ export class ClientServerService {
//#endregion

//region noindex pages
const renderNoIndexBase = async (reply: FastifyReply) => {
const meta = await this.metaService.fetch();
reply.header('Cache-Control', 'public, max-age=30');
return await reply.view('noindex', {
img: meta.bannerUrl,
url: this.config.url,
title: meta.name ?? 'Misskey',
desc: meta.description,
...await this.generateCommonPugData(meta),
});
};

// Tags
fastify.get<{ Params: { clip: string; } }>('/tags/:tag', async (request, reply) => {
return await renderNoIndexBase(reply);
return await renderBase(reply, { noindex: true });
});

// User with Tags
fastify.get<{ Params: { clip: string; } }>('/user-tags/:tag', async (request, reply) => {
return await renderNoIndexBase(reply);
return await renderBase(reply, { noindex: true });
});
//endregion

Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/server/web/views/base.pug
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ html
block title
= title || 'Misskey'

if noindex
meta(name='robots' content='noindex')

block desc
meta(name='description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')

Expand Down
5 changes: 0 additions & 5 deletions packages/backend/src/server/web/views/noindex.pug

This file was deleted.

0 comments on commit 86dd815

Please sign in to comment.