1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Support multiple rel="me"

This commit is contained in:
Chocobozzz 2025-03-27 14:15:33 +01:00
parent 5efbbcbeb1
commit c627e6d834
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 14 additions and 9 deletions

View file

@ -30,7 +30,7 @@ export type TagsOptions = {
escapedTitle?: string
escapedTruncatedDescription?: string
relMe?: string
relMe?: string[]
image?: {
url: string
@ -59,7 +59,6 @@ type HookContext = {
}
export class TagsHtml {
static addTitleTag (htmlStringPage: string, title?: string) {
let text = title || CONFIG.INSTANCE.NAME
if (title) text += ` - ${CONFIG.INSTANCE.NAME}`
@ -81,7 +80,7 @@ export class TagsHtml {
const html = parse(content)
return html.querySelector('a[rel=me]')?.getAttribute('href') || undefined
return html.querySelectorAll('a[rel=me]').map(e => e.getAttribute('href'))
}
// ---------------------------------------------------------------------------
@ -118,7 +117,9 @@ export class TagsHtml {
// OEmbed
for (const oembedLinkTag of oembedLinkTags) {
// eslint-disable-next-line max-len
tagsStr += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${escapeAttribute(oembedLinkTag.escapedTitle)}" />`
tagsStr += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${
escapeAttribute(oembedLinkTag.escapedTitle)
}" />`
}
// Schema.org
@ -126,8 +127,10 @@ export class TagsHtml {
tagsStr += `<script type="application/ld+json">${JSON.stringify(schemaTags)}</script>`
}
if (relMe) {
tagsStr += `<link href="${escapeAttribute(relMe)}" rel="me">`
if (Array.isArray(relMe)) {
for (const relMeLink of relMe) {
tagsStr += `<link href="${escapeAttribute(relMeLink)}" rel="me">`
}
}
// SEO, use origin URL