mirror of https://github.com/Chocobozzz/PeerTube
Fix profile page JSONLD
parent
cf843c3f12
commit
2fde12d7e1
|
@ -80,6 +80,10 @@ export class ActorHtml {
|
||||||
ogType,
|
ogType,
|
||||||
twitterCard,
|
twitterCard,
|
||||||
schemaType,
|
schemaType,
|
||||||
|
jsonldProfile: {
|
||||||
|
createdAt: entity.createdAt,
|
||||||
|
updatedAt: entity.updatedAt
|
||||||
|
},
|
||||||
|
|
||||||
indexationPolicy: entity.Actor.isOwned()
|
indexationPolicy: entity.Actor.isOwned()
|
||||||
? 'always'
|
? 'always'
|
||||||
|
|
|
@ -11,10 +11,16 @@ type Tags = {
|
||||||
|
|
||||||
url?: string
|
url?: string
|
||||||
|
|
||||||
schemaType?: string
|
|
||||||
ogType?: string
|
ogType?: string
|
||||||
twitterCard?: 'player' | 'summary' | 'summary_large_image'
|
twitterCard?: 'player' | 'summary' | 'summary_large_image'
|
||||||
|
|
||||||
|
schemaType?: string
|
||||||
|
|
||||||
|
jsonldProfile?: {
|
||||||
|
createdAt: Date
|
||||||
|
updatedAt: Date
|
||||||
|
}
|
||||||
|
|
||||||
list?: {
|
list?: {
|
||||||
numberOfItems: number
|
numberOfItems: number
|
||||||
}
|
}
|
||||||
|
@ -195,6 +201,28 @@ export class TagsHtml {
|
||||||
static generateSchemaTagsOptions (tags: Tags, context: HookContext) {
|
static generateSchemaTagsOptions (tags: Tags, context: HookContext) {
|
||||||
if (!tags.schemaType) return
|
if (!tags.schemaType) return
|
||||||
|
|
||||||
|
if (tags.schemaType === 'ProfilePage') {
|
||||||
|
if (!tags.jsonldProfile) throw new Error('Missing `jsonldProfile` with ProfilePage schema type')
|
||||||
|
|
||||||
|
const profilePageSchema = {
|
||||||
|
'@context': 'http://schema.org',
|
||||||
|
'@type': tags.schemaType,
|
||||||
|
|
||||||
|
'dateCreated': tags.jsonldProfile.createdAt.toISOString(),
|
||||||
|
'dateModified': tags.jsonldProfile.updatedAt.toISOString(),
|
||||||
|
|
||||||
|
'mainEntity': {
|
||||||
|
'@id': '#main-author',
|
||||||
|
'@type': 'Person',
|
||||||
|
'name': tags.escapedTitle,
|
||||||
|
'description': tags.escapedTruncatedDescription,
|
||||||
|
'image': tags.image.url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Hooks.wrapObject(profilePageSchema, 'filter:html.client.json-ld.result', context)
|
||||||
|
}
|
||||||
|
|
||||||
const schema = {
|
const schema = {
|
||||||
'@context': 'http://schema.org',
|
'@context': 'http://schema.org',
|
||||||
'@type': tags.schemaType,
|
'@type': tags.schemaType,
|
||||||
|
|
Loading…
Reference in New Issue