-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revisions for March 2023 * Add land acknowledgement
- Loading branch information
1 parent
119b947
commit 4568bf7
Showing
14 changed files
with
196 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ yarn-error.log* | |
|
||
/.tmp | ||
/.envrc | ||
|
||
/public/_redirects.contentful |
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
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 |
---|---|---|
@@ -1,7 +1,33 @@ | ||
export const config = { | ||
space_id: process.env.CONTENTFUL_SPACE_ID, | ||
deploy_access_token: process.env.CONTENTFUL_DELIVERY_ACCESS_TOKEN, | ||
preview_access_token: process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN, | ||
import { INLINES } from '@contentful/rich-text-types' | ||
|
||
const CONTENTFUL_PREVIEW = (process.env.CONTENTFUL_PREVIEW || '').trim().toLowerCase() | ||
const CONTENTFUL_SPACE_ID = process.env.CONTENTFUL_SPACE_ID | ||
const CONTENTFUL_DELIVERY_ACCESS_TOKEN = process.env.CONTENTFUL_DELIVERY_ACCESS_TOKEN | ||
const CONTENTFUL_PREVIEW_ACCESS_TOKEN = process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN | ||
|
||
export const preview = !['', '0', 'f', 'false', 'n', 'no', 'off'].includes(CONTENTFUL_PREVIEW) | ||
export const access_token = preview ? CONTENTFUL_PREVIEW_ACCESS_TOKEN : CONTENTFUL_DELIVERY_ACCESS_TOKEN | ||
export const host = preview ? 'preview.contentful.com' : 'cdn.contentful.com' | ||
export const space_id = CONTENTFUL_SPACE_ID | ||
|
||
const renderOptions = { | ||
renderNode: { | ||
[INLINES.ASSET_HYPERLINK]: (node, children) => { | ||
if (!node) { | ||
return | ||
} | ||
|
||
const { file, title } = node.data.target.fields | ||
const aProps = {} | ||
if (Boolean(file.contentType.match(/^application\/pdf($|;)/i))) { | ||
aProps.download = file.fileName | ||
aProps.target = '_blank' | ||
} | ||
|
||
return <a href={file.url} title={title} {...aProps}>{children}</a> | ||
}, | ||
} | ||
} | ||
|
||
export const config = { preview, access_token, host, space_id, renderOptions } | ||
export default config |
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,35 @@ | ||
import path from 'path' | ||
import { writeFile } from 'fs/promises' | ||
import { fetchRedirects } from './entries' | ||
|
||
const mediaTarget = (media) => media && `https:${media.fields.file.url}` | ||
const entryTarget = (entry) => { | ||
if (!entry) return | ||
|
||
const contentType = entry.sys.contentType.sys.id | ||
const slug = entry.fields.slug | ||
|
||
return `/${contentType}/${slug}` | ||
} | ||
const urlTarget = (url) => url | ||
|
||
export async function writeRedirects() { | ||
const file_name = path.join(__dirname, '..', '..', '..', 'public', '_redirects.contentful') | ||
const redirects = await fetchRedirects() | ||
|
||
const data = redirects.map(redirect => { | ||
const { alias, code, media, entry, url } = redirect.fields | ||
const statusCode = code.split(' ')[0] | ||
const target = mediaTarget(media) || entryTarget(entry) || urlTarget(url) | ||
|
||
if (!target) { | ||
throw new Error(`invalid target: ${target}`) | ||
} | ||
|
||
return { alias, target, statusCode } | ||
}) | ||
|
||
const output = data.map(({ alias, target, statusCode }) => [`/${alias}`, target, `${statusCode}!`].join(' ')).join('\n') | ||
|
||
await writeFile(file_name, output) | ||
} |
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,10 @@ | ||
import { documentToHtmlString } from '@contentful/rich-text-html-renderer' | ||
import { documentToReactComponents } from '@contentful/rich-text-react-renderer' | ||
import config from './config' | ||
|
||
export const renderComponents = | ||
(content, options = config.renderOptions) => | ||
documentToReactComponents(content, options) | ||
|
||
export const render = { renderComponents, documentToHtmlString, documentToReactComponents } | ||
export default render |
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 |
---|---|---|
@@ -1,3 +1,40 @@ | ||
import { DateTime } from 'luxon' | ||
|
||
export const YEAR = DateTime.now().year | ||
|
||
// size: short, med(ium)?, full, huge | ||
export const formatDateTime = (date, options = {}) => { | ||
const dt = DateTime.fromISO(date) | ||
const { size } = { size: 'medium', ...options } | ||
|
||
switch (size) { | ||
// TODO: case 'full': {} | ||
|
||
case 'short': { | ||
// year … Jan 1, 2000 at 1pm | ||
// … Jan 1 at 1pm | ||
// weekday … Mon, Jan 1 at 1pm | ||
// weekday,minutes … Mon, Jan 1 at 1:30pm | ||
// weekday,year,minutes … Mon, Jan 1, 2000 at 1:30pm | ||
const { year, weekday, minutes } = { year: true, weekday: false, minutes: false, ...options } | ||
const wd = weekday ? `${dt.toFormat('ccc')}, ` : '' | ||
const md = dt.toFormat('LLL d') | ||
const y = year ? `, ${dt.toFormat('yyyy')}` : '' | ||
const t = minutes ? dt.toFormat('t').toLowerCase().replace(' ', '') : dt.toFormat('h') + dt.toFormat('a').toLowerCase() | ||
return [wd, md, y, ' at ', t].join('') | ||
} | ||
case 'med': | ||
case 'medium': | ||
default: { | ||
// January 1, 2000 at 1:30 PM | ||
// Monday, January 1, 2000 at 1:30 PM | ||
// Monday, January 1, at 1:30 PM | ||
const { year, weekday } = { year: true, weekday: false, ...options } | ||
const wd = weekday ? `${dt.toFormat('cccc')}, ` : '' | ||
const md = dt.toFormat('LLLL d') | ||
const y = year ? `, ${dt.toFormat('yyyy')}` : '' | ||
const t = ` at ${dt.toFormat('t')}` | ||
return [wd, md, y, t].join('') | ||
} | ||
} | ||
} |
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