diff --git a/prismicCustomTypes.md b/prismicCustomTypes.md index 2c45b25e16..5b3ff0236c 100644 --- a/prismicCustomTypes.md +++ b/prismicCustomTypes.md @@ -113,73 +113,156 @@ name: `sponsor` JSON: ``` { - "Main": { - "title": { - "type": "StructuredText", - "config": { - "single": "heading6", - "label": "Title", - "placeholder": "Sponsor(s) card title" + "Main" : { + "title" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "label" : "Title", + "placeholder" : "Sponsor(s) card title" } }, - "language": { - "type": "StructuredText", + "language" : { + "type" : "StructuredText", + "config" : { + "single" : "heading6", + "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" + } + }, + "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" + } + }, + "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" + } + } + }, + "label" : "Sponsor's info" + } + } + } +} +``` + +### 3. Footer custom type + +name: `footer` + +JSON: +``` +{ + "Main": { + "title": { + "type": "Text", "config": { - "single": "heading6", - "label": "language", - "placeholder": "Language (en, es or fr)" + "label": "Title" } }, "order": { - "type": "StructuredText", + "type": "Number", "config": { - "single": "heading6", - "label": "Order", - "placeholder": "The order you wish the sponsor to appear" + "label": "Order" } }, "items": { "type": "Group", "config": { "fields": { - "logo": { - "type": "Image", + "item_title": { + "type": "Text", "config": { - "constraint": {}, - "thumbnails": [], - "label": "Logo" + "label": "Item Title" } }, - "name": { - "type": "StructuredText", + "item_url": { + "type": "Link", "config": { - "single": "heading5", - "label": "name", - "placeholder": "Sponsor's name" + "label": "Item URL", + "select": null, + "allowTargetBlank": true, + "placeholder": "External URL (outside site)" } }, - "description": { - "type": "StructuredText", + "path": { + "type": "Text", "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" + "label": "Path" + } + } + }, + "label": "Items" + } + }, + "social": { + "type": "Group", + "config": { + "fields": { + "name": { + "type": "Text", + "config": { + "label": "Name", + "placeholder": "twitter/facebook/github/linked" } }, - "link": { + "url": { "type": "Link", "config": { - "label": "link", - "select": null, "allowTargetBlank": true, - "placeholder": "Logo's link" + "label": "url", + "placeholder": "URL to your social media account", + "select": null + } + }, + "path": { + "type": "Text", + "config": { + "label": "Path" } } }, - "label": "Sponsor's info" + "label": "social" } } } } -``` \ No newline at end of file +``` diff --git a/site/gatsby-site/src/components/layout/Footer.js b/site/gatsby-site/src/components/layout/Footer.js index 698be44d2b..d981916249 100644 --- a/site/gatsby-site/src/components/layout/Footer.js +++ b/site/gatsby-site/src/components/layout/Footer.js @@ -30,6 +30,29 @@ export default function Footer() { } } } + allPrismicFooter(sort: { data: { order: ASC } }) { + edges { + node { + data { + title + items { + item_title + item_url { + url + } + path + } + order + social { + name + url { + url + } + } + } + } + } + } } `); @@ -37,8 +60,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; + + let items = group.node.data.items.map((item) => { + return { + title: item.item_title, + url: item.item_url?.url || item.path, + }; + }); + + footerContent.push({ + title, + items, + socialItems: group.node.data.social.map((item) => { + return { + name: item.name, + url: item.url?.url || item.path, + }; + }), + }); + }); + } 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 +114,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 + +
+ + + + + + + + + + + + + + + + + + + +
- + )} ); }