generated from cloud-gov/.github
-
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.
feat: add api keys, globals, pages, other previewer updates
- Loading branch information
Showing
23 changed files
with
608 additions
and
512 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
import { getCachedGlobal } from '@/utilities/getGlobals' | ||
import Link from 'next/link' | ||
import React from 'react' | ||
|
||
import type { Footer } from '@/payload-types' | ||
|
||
import { ThemeSelector } from '@/providers/Theme/ThemeSelector' | ||
import { CMSLink } from '@/components/Link' | ||
import { Logo } from '@/components/Logo/Logo' | ||
|
||
export async function Footer() { | ||
const footerData: Footer = await getCachedGlobal('footer', 1)() | ||
|
||
const navItems = footerData?.navItems || [] | ||
|
||
return ( | ||
<footer className="mt-auto border-t border-border bg-black dark:bg-card text-white"> | ||
<div className="container py-8 gap-8 flex flex-col md:flex-row md:justify-between"> | ||
<Link className="flex items-center" href="/"> | ||
<Logo /> | ||
</Link> | ||
|
||
<div className="flex flex-col-reverse items-start md:flex-row gap-4 md:items-center"> | ||
<ThemeSelector /> | ||
<nav className="flex flex-col md:flex-row gap-4"> | ||
{navItems.map(({ link }, i) => { | ||
return <CMSLink className="text-white" key={i} {...link} /> | ||
})} | ||
</nav> | ||
</div> | ||
</div> | ||
</footer> | ||
) | ||
} |
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,13 @@ | ||
'use client' | ||
import { Header } from '@/payload-types' | ||
import { RowLabelProps, useRowLabel } from '@payloadcms/ui' | ||
|
||
export const RowLabel: React.FC<RowLabelProps> = () => { | ||
const data = useRowLabel<NonNullable<Header['navItems']>[number]>() | ||
|
||
const label = data?.data?.link?.label | ||
? `Nav item ${data.rowNumber !== undefined ? data.rowNumber + 1 : ''}: ${data?.data?.link?.label}` | ||
: 'Row' | ||
|
||
return <div>{label}</div> | ||
} |
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,32 @@ | ||
import type { GlobalConfig } from 'payload' | ||
|
||
import { link } from '@/fields/link' | ||
import { revalidateFooter } from './hooks/revalidateFooter' | ||
|
||
export const Footer: GlobalConfig = { | ||
slug: 'footer', | ||
access: { | ||
read: () => true, | ||
}, | ||
fields: [ | ||
{ | ||
name: 'navItems', | ||
type: 'array', | ||
fields: [ | ||
link({ | ||
appearances: false, | ||
}), | ||
], | ||
maxRows: 6, | ||
admin: { | ||
initCollapsed: true, | ||
components: { | ||
RowLabel: '@/Footer/RowLabel#RowLabel', | ||
}, | ||
}, | ||
}, | ||
], | ||
hooks: { | ||
afterChange: [revalidateFooter], | ||
}, | ||
} |
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,13 @@ | ||
import type { GlobalAfterChangeHook } from 'payload' | ||
|
||
import { revalidateTag } from 'next/cache' | ||
|
||
export const revalidateFooter: GlobalAfterChangeHook = ({ doc, req: { payload, context } }) => { | ||
if (!context.disableRevalidate) { | ||
payload.logger.info(`Revalidating footer`) | ||
|
||
revalidateTag('global_footer') | ||
} | ||
|
||
return doc | ||
} |
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,42 @@ | ||
'use client' | ||
import { useHeaderTheme } from '@/providers/HeaderTheme' | ||
import Link from 'next/link' | ||
import { usePathname } from 'next/navigation' | ||
import React, { useEffect, useState } from 'react' | ||
|
||
import type { Header } from '@/payload-types' | ||
|
||
import { Logo } from '@/components/Logo/Logo' | ||
import { HeaderNav } from './Nav' | ||
|
||
interface HeaderClientProps { | ||
data: Header | ||
} | ||
|
||
export const HeaderClient: React.FC<HeaderClientProps> = ({ data }) => { | ||
/* Storing the value in a useState to avoid hydration errors */ | ||
const [theme, setTheme] = useState<string | null>(null) | ||
const { headerTheme, setHeaderTheme } = useHeaderTheme() | ||
const pathname = usePathname() | ||
|
||
useEffect(() => { | ||
setHeaderTheme(null) | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [pathname]) | ||
|
||
useEffect(() => { | ||
if (headerTheme && headerTheme !== theme) setTheme(headerTheme) | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [headerTheme]) | ||
|
||
return ( | ||
<header className="container relative z-20 " {...(theme ? { 'data-theme': theme } : {})}> | ||
<div className="py-8 flex justify-between"> | ||
<Link href="/"> | ||
<Logo loading="eager" priority="high" className="invert dark:invert-0" /> | ||
</Link> | ||
<HeaderNav data={data} /> | ||
</div> | ||
</header> | ||
) | ||
} |
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,11 @@ | ||
import { HeaderClient } from './Component.client' | ||
import { getCachedGlobal } from '@/utilities/getGlobals' | ||
import React from 'react' | ||
|
||
import type { Header } from '@/payload-types' | ||
|
||
export async function Header() { | ||
const headerData: Header = await getCachedGlobal('header', 1)() | ||
|
||
return <HeaderClient data={headerData} /> | ||
} |
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,25 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
|
||
import type { Header as HeaderType } from '@/payload-types' | ||
|
||
import { CMSLink } from '@/components/Link' | ||
import Link from 'next/link' | ||
import { SearchIcon } from 'lucide-react' | ||
|
||
export const HeaderNav: React.FC<{ data: HeaderType }> = ({ data }) => { | ||
const navItems = data?.navItems || [] | ||
|
||
return ( | ||
<nav className="flex gap-3 items-center"> | ||
{navItems.map(({ link }, i) => { | ||
return <CMSLink key={i} {...link} appearance="link" /> | ||
})} | ||
<Link href="/search"> | ||
<span className="sr-only">Search</span> | ||
<SearchIcon className="w-5 text-primary" /> | ||
</Link> | ||
</nav> | ||
) | ||
} |
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,13 @@ | ||
'use client' | ||
import { Header } from '@/payload-types' | ||
import { RowLabelProps, useRowLabel } from '@payloadcms/ui' | ||
|
||
export const RowLabel: React.FC<RowLabelProps> = () => { | ||
const data = useRowLabel<NonNullable<Header['navItems']>[number]>() | ||
|
||
const label = data?.data?.link?.label | ||
? `Nav item ${data.rowNumber !== undefined ? data.rowNumber + 1 : ''}: ${data?.data?.link?.label}` | ||
: 'Row' | ||
|
||
return <div>{label}</div> | ||
} |
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,32 @@ | ||
import type { GlobalConfig } from 'payload' | ||
|
||
import { link } from '@/fields/link' | ||
import { revalidateHeader } from './hooks/revalidateHeader' | ||
|
||
export const Header: GlobalConfig = { | ||
slug: 'header', | ||
access: { | ||
read: () => true, | ||
}, | ||
fields: [ | ||
{ | ||
name: 'navItems', | ||
type: 'array', | ||
fields: [ | ||
link({ | ||
appearances: false, | ||
}), | ||
], | ||
maxRows: 6, | ||
admin: { | ||
initCollapsed: true, | ||
components: { | ||
RowLabel: '@/Header/RowLabel#RowLabel', | ||
}, | ||
}, | ||
}, | ||
], | ||
hooks: { | ||
afterChange: [revalidateHeader], | ||
}, | ||
} |
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,13 @@ | ||
import type { GlobalAfterChangeHook } from 'payload' | ||
|
||
import { revalidateTag } from 'next/cache' | ||
|
||
export const revalidateHeader: GlobalAfterChangeHook = ({ doc, req: { payload, context } }) => { | ||
if (!context.disableRevalidate) { | ||
payload.logger.info(`Revalidating header`) | ||
|
||
revalidateTag('global_header') | ||
} | ||
|
||
return doc | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.