From 3c287620d32de57c6d0a8202736e529685cc73ba Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 27 Jul 2023 12:44:56 -0300 Subject: [PATCH 1/5] Fetch footer from Prismic or fallback to current config --- .../src/components/layout/Footer.js | 356 ++++++++++++------ 1 file changed, 247 insertions(+), 109 deletions(-) diff --git a/site/gatsby-site/src/components/layout/Footer.js b/site/gatsby-site/src/components/layout/Footer.js index 698be44d2b..f88482c156 100644 --- a/site/gatsby-site/src/components/layout/Footer.js +++ b/site/gatsby-site/src/components/layout/Footer.js @@ -30,6 +30,36 @@ export default function Footer() { } } } + allPrismicFooter(sort: { data: { order: { text: ASC } } }) { + edges { + node { + data { + title { + text + } + items { + item_title { + text + } + item_url { + url + } + path { + text + } + } + social { + name { + text + } + url { + url + } + } + } + } + } + } } `); @@ -37,8 +67,53 @@ export default function Footer() { site: { siteMetadata: { githubUrl, facebookUrl, linkedInUrl }, }, + allPrismicFooter, } = data; + const footerContent = []; + + if (allPrismicFooter.edges.length > 0) { + allPrismicFooter.edges.forEach((group) => { + const title = group.node.data.title.text; + + let items = group.node.data.items.map((item) => { + return { + title: item.item_title?.text, + url: item.item_url?.url || item.path?.text, + }; + }); + + footerContent.push({ + title, + items, + socialItems: group.node.data.social.map((item) => { + return { + name: item.name?.text, + url: item.url?.url || item.path?.text, + }; + }), + }); + }); + } else { + //Fallback to config + config.footer.navConfig.map((group) => { + const title = group.title; + + const items = group.items.map((item) => { + return { + title: item.title, + url: item.url, + label: item.label, + }; + }); + + footerContent.push({ + title, + items, + }); + }); + } + const { t } = useTranslation(['footer']); return ( @@ -46,117 +121,180 @@ export default function Footer() { id="main-footer" className="bg-text-light-gray relative sm:grid sm:grid-cols-2 md:grid-cols-4 gap-5 p-5 z-50" > - {config.footer.navConfig.map((group) => ( -
-

{t(group.title)}

- +
+ ); + })} + + {allPrismicFooter.edges.length <= 0 && ( +
+

2023 - AI Incident Database

+ + + Terms of use + +
+ + Privacy Policy + +
+ + + + + + + + + + + + + + + + + + + +
- + )} ); } From 0d878e6a02a49bdc95468941fb313d8aa6a69132 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 27 Jul 2023 12:53:53 -0300 Subject: [PATCH 2/5] Update prismicCustomTypes.md --- prismicCustomTypes.md | 92 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/prismicCustomTypes.md b/prismicCustomTypes.md index b801c696b5..3b1a77e6cb 100644 --- a/prismicCustomTypes.md +++ b/prismicCustomTypes.md @@ -105,3 +105,95 @@ JSON: } } ``` + + +### 2. Footer custom type + +name: `footer` + +JSON: +``` +{ + "Main" : { + "title" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "label" : "Title" + } + }, + "order" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "label" : "Order" + } + }, + "items" : { + "type" : "Group", + "config" : { + "fields" : { + "item_title" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "label" : "Title" + } + }, + "item_url" : { + "type" : "Link", + "config" : { + "label" : "Item URL", + "select" : null, + "allowTargetBlank" : true, + "placeholder" : "External URL (outside site)" + } + }, + "path" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "label" : "path", + "placeholder" : "Path inside site example: /about" + } + } + }, + "label" : "Items" + } + }, + "social" : { + "type" : "Group", + "config" : { + "fields" : { + "name" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "label" : "name", + "placeholder" : "twitter/github/facebook/instagram/linkedin" + } + }, + "url" : { + "type" : "Link", + "config" : { + "allowTargetBlank" : true, + "label" : "url", + "placeholder" : "URL to your social media account", + "select" : null + } + }, + "path" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "label" : "path", + "placeholder" : "URL to inside the site" + } + } + }, + "label" : "social" + } + } + } +} +``` From 4da8c349da64de16a71f48b47f10b4cdfb70b359 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Fri, 28 Jul 2023 14:44:27 -0300 Subject: [PATCH 3/5] Fix prismic footer custom type format --- prismicCustomTypes.md | 30 +++++++------------ .../src/components/layout/Footer.js | 28 +++++++---------- 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/prismicCustomTypes.md b/prismicCustomTypes.md index 125bf2ea51..641a546dc2 100644 --- a/prismicCustomTypes.md +++ b/prismicCustomTypes.md @@ -193,16 +193,14 @@ JSON: { "Main" : { "title" : { - "type" : "StructuredText", + "type" : "Text", "config" : { - "single" : "heading6", "label" : "Title" } }, "order" : { - "type" : "StructuredText", + "type" : "Text", "config" : { - "single" : "heading6", "label" : "Order" } }, @@ -211,10 +209,9 @@ JSON: "config" : { "fields" : { "item_title" : { - "type" : "StructuredText", + "type" : "Text", "config" : { - "single" : "heading6", - "label" : "Title" + "label" : "Item Title" } }, "item_url" : { @@ -227,11 +224,9 @@ JSON: } }, "path" : { - "type" : "StructuredText", + "type" : "Text", "config" : { - "single" : "heading6", - "label" : "path", - "placeholder" : "Path inside site example: /about" + "label" : "Path" } } }, @@ -243,11 +238,10 @@ JSON: "config" : { "fields" : { "name" : { - "type" : "StructuredText", + "type" : "Text", "config" : { - "single" : "heading6", - "label" : "name", - "placeholder" : "twitter/github/facebook/instagram/linkedin" + "label" : "Name", + "placeholder" : "twitter/facebook/github/linked" } }, "url" : { @@ -260,11 +254,9 @@ JSON: } }, "path" : { - "type" : "StructuredText", + "type" : "Text", "config" : { - "single" : "heading6", - "label" : "path", - "placeholder" : "URL to inside the site" + "label" : "Path" } } }, diff --git a/site/gatsby-site/src/components/layout/Footer.js b/site/gatsby-site/src/components/layout/Footer.js index f88482c156..e225d94b62 100644 --- a/site/gatsby-site/src/components/layout/Footer.js +++ b/site/gatsby-site/src/components/layout/Footer.js @@ -30,28 +30,20 @@ export default function Footer() { } } } - allPrismicFooter(sort: { data: { order: { text: ASC } } }) { + allPrismicFooter(sort: { data: { order: ASC } }) { edges { node { data { - title { - text - } + title items { - item_title { - text - } + item_title item_url { url } - path { - text - } + path } social { - name { - text - } + name url { url } @@ -74,12 +66,12 @@ export default function Footer() { if (allPrismicFooter.edges.length > 0) { allPrismicFooter.edges.forEach((group) => { - const title = group.node.data.title.text; + const title = group.node.data.title; let items = group.node.data.items.map((item) => { return { - title: item.item_title?.text, - url: item.item_url?.url || item.path?.text, + title: item.item_title, + url: item.item_url?.url || item.path, }; }); @@ -88,8 +80,8 @@ export default function Footer() { items, socialItems: group.node.data.social.map((item) => { return { - name: item.name?.text, - url: item.url?.url || item.path?.text, + name: item.name, + url: item.url?.url || item.path, }; }), }); From f1dc0df098b6291edb6d3a4a790a783d14d53cb4 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 31 Jul 2023 10:13:50 -0300 Subject: [PATCH 4/5] Fix order in custom type for footer and improve custom type for sponsors --- prismicCustomTypes.md | 196 +++++++++--------- .../src/components/layout/Footer.js | 1 + 2 files changed, 97 insertions(+), 100 deletions(-) diff --git a/prismicCustomTypes.md b/prismicCustomTypes.md index 641a546dc2..8770cc43ab 100644 --- a/prismicCustomTypes.md +++ b/prismicCustomTypes.md @@ -113,71 +113,67 @@ name: `sponsor` JSON: ``` { - "Main": { - "title": { - "type": "StructuredText", - "config": { - "single": "heading6", - "label": "Title", - "placeholder": "Sponsor(s) card title" + "Main" : { + "title" : { + "type" : "Text", + "config" : { + "label" : "Title", + "placeholder" : "Sponsor(s) card title" } }, - "language": { - "type": "StructuredText", - "config": { - "single": "heading6", - "label": "language", - "placeholder": "Language (en, es or fr)" + "language" : { + "type" : "Text", + "config" : { + "label" : "Language", + "placeholder" : "Language (en, es or fr)" } }, - "order": { - "type": "StructuredText", - "config": { - "single": "heading6", - "label": "Order", - "placeholder": "The order you wish the sponsor to appear" + "order" : { + "type" : "Number", + "config" : { + "label" : "Order", + "placeholder" : "The order you wish the sponsor to appear" } }, - "items": { - "type": "Group", - "config": { - "fields": { - "logo": { - "type": "Image", - "config": { - "constraint": {}, - "thumbnails": [], - "label": "Logo" + "items" : { + "type" : "Group", + "config" : { + "fields" : { + "logo" : { + "type" : "Image", + "config" : { + "constraint" : { }, + "thumbnails" : [ ], + "label" : "Logo" } }, - "name": { - "type": "StructuredText", - "config": { - "single": "heading5", - "label": "name", - "placeholder": "Sponsor's name" + "name" : { + "type" : "Text", + "config" : { + "label" : "Name", + "placeholder" : "Sponsor's name" } }, - "description": { - "type": "StructuredText", - "config": { - "multi": "paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl", - "allowTargetBlank": true, - "label": "description", - "placeholder": "Sponsor's description" + "description" : { + "type" : "StructuredText", + "config" : { + "multi" : "paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl", + "allowTargetBlank" : true, + "label" : "description", + "placeholder" : "Sponsor's description" } }, - "link": { - "type": "Link", - "config": { - "label": "link", - "select": null, - "allowTargetBlank": true, - "placeholder": "Logo's link" + "link" : { + "type" : "Link", + "config" : { + "label" : "link", + "select" : null, + "allowTargetBlank" : true, + "placeholder" : "Logo's link" } } }, - "label": "Sponsor's info" + "label" : "Sponsor's info" } } } @@ -191,76 +187,76 @@ name: `footer` JSON: ``` { - "Main" : { - "title" : { - "type" : "Text", - "config" : { - "label" : "Title" + "Main": { + "title": { + "type": "Text", + "config": { + "label": "Title" } }, - "order" : { - "type" : "Text", - "config" : { - "label" : "Order" + "order": { + "type": "Number", + "config": { + "label": "Order" } }, - "items" : { - "type" : "Group", - "config" : { - "fields" : { - "item_title" : { - "type" : "Text", - "config" : { - "label" : "Item Title" + "items": { + "type": "Group", + "config": { + "fields": { + "item_title": { + "type": "Text", + "config": { + "label": "Item Title" } }, - "item_url" : { - "type" : "Link", - "config" : { - "label" : "Item URL", - "select" : null, - "allowTargetBlank" : true, - "placeholder" : "External URL (outside site)" + "item_url": { + "type": "Link", + "config": { + "label": "Item URL", + "select": null, + "allowTargetBlank": true, + "placeholder": "External URL (outside site)" } }, - "path" : { - "type" : "Text", - "config" : { - "label" : "Path" + "path": { + "type": "Text", + "config": { + "label": "Path" } } }, - "label" : "Items" + "label": "Items" } }, - "social" : { - "type" : "Group", - "config" : { - "fields" : { - "name" : { - "type" : "Text", - "config" : { - "label" : "Name", - "placeholder" : "twitter/facebook/github/linked" + "social": { + "type": "Group", + "config": { + "fields": { + "name": { + "type": "Text", + "config": { + "label": "Name", + "placeholder": "twitter/facebook/github/linked" } }, - "url" : { - "type" : "Link", - "config" : { - "allowTargetBlank" : true, - "label" : "url", - "placeholder" : "URL to your social media account", - "select" : null + "url": { + "type": "Link", + "config": { + "allowTargetBlank": true, + "label": "url", + "placeholder": "URL to your social media account", + "select": null } }, - "path" : { - "type" : "Text", - "config" : { - "label" : "Path" + "path": { + "type": "Text", + "config": { + "label": "Path" } } }, - "label" : "social" + "label": "social" } } } diff --git a/site/gatsby-site/src/components/layout/Footer.js b/site/gatsby-site/src/components/layout/Footer.js index e225d94b62..d981916249 100644 --- a/site/gatsby-site/src/components/layout/Footer.js +++ b/site/gatsby-site/src/components/layout/Footer.js @@ -42,6 +42,7 @@ export default function Footer() { } path } + order social { name url { From c7513d57c233e6e1c96aa2fe085f7f73bab5cdb7 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 31 Jul 2023 10:34:40 -0300 Subject: [PATCH 5/5] Revert sponsor changes --- prismicCustomTypes.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/prismicCustomTypes.md b/prismicCustomTypes.md index 8770cc43ab..5b3ff0236c 100644 --- a/prismicCustomTypes.md +++ b/prismicCustomTypes.md @@ -115,22 +115,25 @@ JSON: { "Main" : { "title" : { - "type" : "Text", + "type" : "StructuredText", "config" : { + "single" : "heading6", "label" : "Title", "placeholder" : "Sponsor(s) card title" } }, "language" : { - "type" : "Text", + "type" : "StructuredText", "config" : { - "label" : "Language", + "single" : "heading6", + "label" : "language", "placeholder" : "Language (en, es or fr)" } }, "order" : { - "type" : "Number", + "type" : "StructuredText", "config" : { + "single" : "heading6", "label" : "Order", "placeholder" : "The order you wish the sponsor to appear" } @@ -148,9 +151,10 @@ JSON: } }, "name" : { - "type" : "Text", + "type" : "StructuredText", "config" : { - "label" : "Name", + "single" : "heading5", + "label" : "name", "placeholder" : "Sponsor's name" } },