seo: align public identity and social metadata
This commit is contained in:
@@ -7,6 +7,15 @@ import type {
|
||||
import { serializeJsonLd } from '../security/serialize-json-ld.ts';
|
||||
import { createSecurityHeaders } from '../security/security-policy.ts';
|
||||
|
||||
interface PlaceJsonLd {
|
||||
'@type': 'Place';
|
||||
address: {
|
||||
'@type': 'PostalAddress';
|
||||
addressLocality: string;
|
||||
addressCountry: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface PersonJsonLd {
|
||||
'@type': 'Person';
|
||||
name: string;
|
||||
@@ -14,6 +23,7 @@ interface PersonJsonLd {
|
||||
description: string;
|
||||
url: string;
|
||||
email: string;
|
||||
homeLocation: PlaceJsonLd;
|
||||
sameAs?: string[];
|
||||
}
|
||||
|
||||
@@ -38,6 +48,12 @@ export interface PageMetadata {
|
||||
url: string;
|
||||
image?: string;
|
||||
};
|
||||
twitter: {
|
||||
card: 'summary' | 'summary_large_image';
|
||||
title: string;
|
||||
description: string;
|
||||
image?: string;
|
||||
};
|
||||
jsonLd: ProfilePageJsonLd;
|
||||
serializedJsonLd: string;
|
||||
jsonLdCspHash: string;
|
||||
@@ -78,12 +94,20 @@ export const createPageMetadata = (
|
||||
description: content.metadata.description,
|
||||
url: site.canonicalUrl,
|
||||
email: `mailto:${content.contact.email}`,
|
||||
homeLocation: {
|
||||
'@type': 'Place',
|
||||
address: {
|
||||
'@type': 'PostalAddress',
|
||||
addressLocality: content.identity.location.city,
|
||||
addressCountry: content.identity.location.countryCode,
|
||||
},
|
||||
},
|
||||
...(sameAs.length === 0 ? {} : { sameAs }),
|
||||
};
|
||||
const jsonLd: ProfilePageJsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'ProfilePage',
|
||||
name: canonicalTitle,
|
||||
name: content.identity.name,
|
||||
description: content.metadata.description,
|
||||
url: site.canonicalUrl,
|
||||
mainEntity,
|
||||
@@ -103,6 +127,12 @@ export const createPageMetadata = (
|
||||
url: site.canonicalUrl,
|
||||
...(image === undefined ? {} : { image }),
|
||||
},
|
||||
twitter: {
|
||||
card: image === undefined ? 'summary' : 'summary_large_image',
|
||||
title: canonicalTitle,
|
||||
description: content.metadata.description,
|
||||
...(image === undefined ? {} : { image }),
|
||||
},
|
||||
jsonLd,
|
||||
serializedJsonLd,
|
||||
jsonLdCspHash: `sha256-${createHash('sha256').update(serializedJsonLd).digest('base64')}`,
|
||||
|
||||
Reference in New Issue
Block a user