From 2a619323706d821780630688b42ba88e23c35ead Mon Sep 17 00:00:00 2001 From: Brian Miller Date: Mon, 28 Jun 2021 11:24:16 -0500 Subject: [PATCH 01/11] Add Ability to pas in custom data Add ability to pass in customMetadata object to spread onto preset google structured data. --- .../page/metadata/google-structured-data/content.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/marko-web/components/page/metadata/google-structured-data/content.js b/packages/marko-web/components/page/metadata/google-structured-data/content.js index 621c3e958..b960c44c3 100644 --- a/packages/marko-web/components/page/metadata/google-structured-data/content.js +++ b/packages/marko-web/components/page/metadata/google-structured-data/content.js @@ -17,7 +17,7 @@ const getImages = (node) => { return images.length ? images : undefined; }; -module.exports = (node) => { +module.exports = (node, customMetadata = {}) => { const publishedISOString = node.published ? (new Date(node.published)).toISOString() : undefined; const updatedISOString = node.updated ? (new Date(node.updated)).toISOString() : undefined; if (node.type === 'video') { @@ -31,6 +31,7 @@ module.exports = (node) => { contentUrl: get(node, 'siteContext.canonicalUrl'), author: getAuthor(node), embedUrl: get(node, 'embedSrc'), + ...customMetadata, }); return structuredData; } @@ -50,6 +51,7 @@ module.exports = (node) => { dateModified: updatedISOString, author: getAuthor(node), description: get(node, 'metadata.description'), + ...customMetadata, }); return structuredData; } From 456efc5a08611dc9b0aae9ae16e5691813c1128c Mon Sep 17 00:00:00 2001 From: Brian Miller Date: Mon, 28 Jun 2021 11:26:48 -0500 Subject: [PATCH 02/11] add required fields to pass custom Metadata Add need calls to pass customMetada from page layout to generation of metadata. --- packages/marko-web/components/page/layouts/content.marko | 4 ++-- packages/marko-web/components/page/layouts/marko.json | 1 + packages/marko-web/components/page/metadata/content.marko | 4 ++-- packages/marko-web/components/page/metadata/marko.json | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/marko-web/components/page/layouts/content.marko b/packages/marko-web/components/page/layouts/content.marko index 675ff2914..0f72cd71d 100644 --- a/packages/marko-web/components/page/layouts/content.marko +++ b/packages/marko-web/components/page/layouts/content.marko @@ -1,4 +1,4 @@ -$ const { id, type } = input; +$ const { customMetadata, id, type } = input; $ const { document } = out.global; <${document} @@ -7,7 +7,7 @@ $ const { document } = out.global; foot=input.foot > <@head> - + <${input.head} /> diff --git a/packages/marko-web/components/page/layouts/marko.json b/packages/marko-web/components/page/layouts/marko.json index 7101f5cc4..3c2d8c573 100644 --- a/packages/marko-web/components/page/layouts/marko.json +++ b/packages/marko-web/components/page/layouts/marko.json @@ -40,6 +40,7 @@ "": {}, "": {}, "": {}, + "@custom-metadata": {}, "@id": "number", "@type": "string", "@attrs": "object" diff --git a/packages/marko-web/components/page/metadata/content.marko b/packages/marko-web/components/page/metadata/content.marko index 2bc997fe6..00dc9f649 100644 --- a/packages/marko-web/components/page/metadata/content.marko +++ b/packages/marko-web/components/page/metadata/content.marko @@ -5,7 +5,7 @@ import buildStructuredData from "./google-structured-data/content"; -$ const { id } = input; +$ const { customMetadata, id } = input; $ const queryFragment = gql` fragment ContentPageMetadataFragment on Content { id @@ -87,7 +87,7 @@ fragment ContentPageMetadataFragment on Content { - $ const structuredData = buildStructuredData(node); + $ const structuredData = buildStructuredData(node, customMetadata);