seo: align public identity and social metadata
This commit is contained in:
@@ -41,10 +41,16 @@ describe('safe metadata', () => {
|
||||
expect(metadata.canonicalUrl).toBe('https://portfolio.example.test/');
|
||||
const previewAsset = manifest.assets.find(({ id }) => id === content.metadata.socialPreviewAssetId)!;
|
||||
expect(metadata.openGraph.image).toBe(`https://portfolio.example.test/assets/${previewAsset.fileName}`);
|
||||
expect(metadata.twitter).toEqual({
|
||||
card: 'summary_large_image',
|
||||
title: metadata.title,
|
||||
description: metadata.description,
|
||||
image: `https://portfolio.example.test/assets/${previewAsset.fileName}`,
|
||||
});
|
||||
expect(metadata.jsonLd).toEqual({
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'ProfilePage',
|
||||
name: 'Luca Pîslaru — System Administrator & Full-Stack Developer',
|
||||
name: 'Luca Pîslaru',
|
||||
description: metadata.description,
|
||||
url: 'https://portfolio.example.test/',
|
||||
mainEntity: {
|
||||
@@ -54,6 +60,14 @@ describe('safe metadata', () => {
|
||||
description: metadata.description,
|
||||
url: 'https://portfolio.example.test/',
|
||||
email: 'mailto:luca.pislaru@gmail.com',
|
||||
homeLocation: {
|
||||
'@type': 'Place',
|
||||
address: {
|
||||
'@type': 'PostalAddress',
|
||||
addressLocality: 'Bucharest',
|
||||
addressCountry: 'RO',
|
||||
},
|
||||
},
|
||||
sameAs: [
|
||||
'https://github.com/LucaPisl',
|
||||
'https://gitlab.com/luca_pisl',
|
||||
@@ -61,10 +75,27 @@ describe('safe metadata', () => {
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(metadata.jsonLd)).not.toMatch(
|
||||
/streetAddress|postalCode|telephone|interactionStatistic|"image"/iu,
|
||||
);
|
||||
const expectedHash = createHash('sha256').update(metadata.serializedJsonLd).digest('base64');
|
||||
expect(metadata.jsonLdCspHash).toBe(`sha256-${expectedHash}`);
|
||||
});
|
||||
|
||||
it('uses a summary card without an image when no social preview is approved', () => {
|
||||
const withoutImage = structuredClone(content);
|
||||
delete withoutImage.metadata.socialPreviewAssetId;
|
||||
|
||||
const metadata = createPageMetadata(withoutImage, manifest, productionSite);
|
||||
|
||||
expect(metadata.openGraph).not.toHaveProperty('image');
|
||||
expect(metadata.twitter).toEqual({
|
||||
card: 'summary',
|
||||
title: 'Luca Pîslaru — System Administrator & Full-Stack Developer',
|
||||
description: content.metadata.description,
|
||||
});
|
||||
});
|
||||
|
||||
it('omits sameAs when no verified social profiles exist', () => {
|
||||
const withoutSocial = structuredClone(content);
|
||||
withoutSocial.contact.social = [];
|
||||
|
||||
Reference in New Issue
Block a user