Skip to content

Commit

Permalink
/tags/user-tags が検索エンジンにインデックスされないように (#13847)
Browse files Browse the repository at this point in the history
* chore(backend): noindex for tag search pages

* docs(changelog): `/tags` と `/user-tags` が検索エンジンにインデックスされないように

* chore: base.pug内でフラグでコントロールするように
  • Loading branch information
anatawa12 authored May 21, 2024
1 parent 3fba768 commit 7bde630
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
- Fix: FTTが有効かつsinceIdのみを指定した場合に帰って来るレスポンスが逆順である問題を修正
- Fix: `/i/notifications``includeTypes``excludeTypes`を指定しているとき、通知が存在するのに空配列を返すことがある問題を修正
- Fix: 複数idを指定する`users/show`が関係ないユーザを返すことがある問題を修正
- Fix: `/tags``/user-tags` が検索エンジンにインデックスされないように

## 2024.3.1

Expand Down
15 changes: 14 additions & 1 deletion 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 @@ -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);

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

0 comments on commit 7bde630

Please sign in to comment.