More flexible way to forbid indexation

pull/6026/head
Chocobozzz 2023-10-19 16:01:46 +02:00
parent 272a902b2a
commit 58daa2d97b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 17 additions and 6 deletions

View File

@ -47,7 +47,7 @@ type Tags = {
url: string
originUrl: string
disallowIndexation?: boolean
indexationPolicy: 'always' | 'never'
embed?: {
url: string
@ -139,7 +139,11 @@ class ClientHtml {
escapedSiteName: escapeHTML(siteName),
escapedTitle: escapeHTML(title),
escapedTruncatedDescription,
disallowIndexation: video.privacy !== VideoPrivacy.PUBLIC,
indexationPolicy: video.privacy !== VideoPrivacy.PUBLIC
? 'never'
: 'always',
image,
embed,
ogType,
@ -203,7 +207,11 @@ class ClientHtml {
escapedSiteName: escapeHTML(siteName),
escapedTitle: escapeHTML(title),
escapedTruncatedDescription,
disallowIndexation: videoPlaylist.privacy !== VideoPlaylistPrivacy.PUBLIC,
indexationPolicy: videoPlaylist.privacy !== VideoPlaylistPrivacy.PUBLIC
? 'never'
: 'always',
embed,
image,
list,
@ -304,7 +312,10 @@ class ClientHtml {
ogType,
twitterCard,
schemaType,
disallowIndexation: !entity.Actor.isOwned()
indexationPolicy: entity.Actor.isOwned()
? 'always'
: 'never'
}, {})
return customHtml
@ -520,7 +531,7 @@ class ClientHtml {
const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues)
const schemaTags = await this.generateSchemaTags(tagsValues, context)
const { url, escapedTitle, embed, originUrl, disallowIndexation } = tagsValues
const { url, escapedTitle, embed, originUrl, indexationPolicy } = tagsValues
const oembedLinkTags: { type: string, href: string, escapedTitle: string }[] = []
@ -568,7 +579,7 @@ class ClientHtml {
// SEO, use origin URL
tagsStr += `<link rel="canonical" href="${originUrl}" />`
if (disallowIndexation) {
if (indexationPolicy === 'never') {
tagsStr += `<meta name="robots" content="noindex" />`
}