From 7bde630820a9270e47f14fcfe5752c98d4716634 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 21 May 2024 11:19:33 +0900 Subject: [PATCH] =?UTF-8?q?`/tags`=20=E3=81=A8=20`/user-tags`=20=E3=81=8C?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3=E3=81=AB?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=83=83=E3=82=AF=E3=82=B9=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=20(#1384?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(backend): noindex for tag search pages * docs(changelog): `/tags` と `/user-tags` が検索エンジンにインデックスされないように * chore: base.pug内でフラグでコントロールするように --- CHANGELOG.md | 1 + .../backend/src/server/web/ClientServerService.ts | 15 ++++++++++++++- packages/backend/src/server/web/views/base.pug | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d1b0a010a..ecacefe84e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ - Fix: FTTが有効かつsinceIdのみを指定した場合に帰って来るレスポンスが逆順である問題を修正 - Fix: `/i/notifications`に `includeTypes`か`excludeTypes`を指定しているとき、通知が存在するのに空配列を返すことがある問題を修正 - Fix: 複数idを指定する`users/show`が関係ないユーザを返すことがある問題を修正 +- Fix: `/tags` と `/user-tags` が検索エンジンにインデックスされないように ## 2024.3.1 diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 1394616752..f35ec8ba31 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -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', { @@ -447,6 +447,7 @@ export class ClientServerService { title: meta.name ?? 'Misskey', desc: meta.description, ...await this.generateCommonPugData(meta), + ...data, }); }; @@ -744,6 +745,18 @@ export class ClientServerService { }); //#endregion + //region noindex pages + // Tags + fastify.get<{ Params: { clip: string; } }>('/tags/:tag', async (request, reply) => { + return await renderBase(reply, { noindex: true }); + }); + + // User with Tags + fastify.get<{ Params: { clip: string; } }>('/user-tags/:tag', async (request, reply) => { + return await renderBase(reply, { noindex: true }); + }); + //endregion + fastify.get('/_info_card_', async (request, reply) => { const meta = await this.metaService.fetch(true); diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug index 1d9146e22a..ec1325e4e9 100644 --- a/packages/backend/src/server/web/views/base.pug +++ b/packages/backend/src/server/web/views/base.pug @@ -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 ✨🚀✨')