-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into ft/codeforafrica-posts-cms
- Loading branch information
Showing
13 changed files
with
161 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import site from "@/codeforafrica/utils/site"; | ||
|
||
function stringifyDescription(description) { | ||
if (!Array.isArray(description)) { | ||
return ""; | ||
} | ||
return description.reduce((result, item) => { | ||
if (item.text) { | ||
// eslint-disable-next-line no-param-reassign | ||
result += item.text; | ||
} | ||
|
||
if (Array.isArray(item.children)) { | ||
// eslint-disable-next-line no-param-reassign | ||
result += stringifyDescription(item.children); | ||
} | ||
return result; | ||
}, ""); | ||
} | ||
|
||
export default function getPageSeoFromMeta(page, settings) { | ||
const { title: pageTitle, meta: pageMeta } = page; | ||
const { | ||
title: metaTitle, | ||
description: metaDescription, | ||
image = {}, | ||
} = pageMeta; | ||
const { title: siteTitle, description: siteDescription } = settings; | ||
const title = | ||
metaTitle || | ||
pageTitle || | ||
siteTitle || | ||
process.env.NEXT_PUBLIC_APP_NAME || | ||
null; | ||
const description = | ||
metaDescription || stringifyDescription(siteDescription) || null; | ||
const titleTemplate = siteTitle ? `%s | ${siteTitle}` : null; | ||
const defaultTitle = siteTitle || null; | ||
const canonical = site.url.replace(/\/+$/, ""); | ||
const openGraph = { | ||
title, | ||
description, | ||
type: "website", | ||
site_name: siteTitle, | ||
}; | ||
if (image.url) { | ||
const { alt, height, mimeType: type, url, width } = image; | ||
openGraph.images = [ | ||
{ | ||
alt: alt || title || defaultTitle, | ||
height, | ||
type, | ||
url, | ||
width, | ||
}, | ||
]; | ||
} | ||
|
||
return { | ||
title, | ||
titleTemplate, | ||
defaultTitle, | ||
description, | ||
canonical, | ||
openGraph, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/codeforafrica/src/payload/blocks/GuidingPrinciples.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const GuidingPrinciples = { | ||
slug: "our-guiding-principles", | ||
imageURL: "/images/cms/blocks/guiding_principles.png", | ||
imageAltText: "Guiding Principles", | ||
fields: [ | ||
{ | ||
name: "title", | ||
label: { | ||
en: "Title", | ||
}, | ||
type: "text", | ||
localized: true, | ||
required: true, | ||
}, | ||
{ | ||
name: "list", | ||
label: { | ||
en: "Guiding Principles", | ||
}, | ||
type: "relationship", | ||
relationTo: "guiding-principles", | ||
hasMany: true, | ||
admin: { | ||
isSortable: true, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
export default GuidingPrinciples; |
34 changes: 34 additions & 0 deletions
34
apps/codeforafrica/src/payload/collections/GuidingPrinciples.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import image from "../fields/image"; | ||
import richText from "../fields/richText"; | ||
|
||
const GuidingPrinciples = { | ||
slug: "guiding-principles", | ||
admin: { | ||
useAsTitle: "title", | ||
}, | ||
fields: [ | ||
{ | ||
name: "title", | ||
label: { | ||
en: "Title", | ||
}, | ||
type: "text", | ||
required: true, | ||
}, | ||
image({ | ||
overrides: { | ||
name: "icon", | ||
required: true, | ||
}, | ||
}), | ||
richText({ | ||
name: "description", | ||
label: { | ||
en: "Description", | ||
}, | ||
required: true, | ||
}), | ||
], | ||
}; | ||
|
||
export default GuidingPrinciples; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters