Added module Links
This commit is contained in:
@@ -35,22 +35,29 @@ export type SiteMetaConfig = {
|
||||
*/
|
||||
export async function readSiteMetaConfig({
|
||||
locale,
|
||||
pagesSlug = 'pages',
|
||||
payload,
|
||||
settings: preloaded,
|
||||
settingsSlug = 'site-settings',
|
||||
siteNameField = 'siteName',
|
||||
}: {
|
||||
locale: string
|
||||
/** Collection holding the homepage. Default 'pages'. */
|
||||
pagesSlug?: string
|
||||
payload: BasePayload
|
||||
/** SiteSettings already read for this locale (depth ≥ 1) — skips the read. */
|
||||
settings?: null | Record<string, unknown>
|
||||
settingsSlug?: string
|
||||
siteNameField?: string
|
||||
}): Promise<SiteMetaConfig> {
|
||||
// depth 1 populates the homepage relationship, so its slug is available
|
||||
// without a second query.
|
||||
const settings = (await payload.findGlobal({
|
||||
slug: settingsSlug as never,
|
||||
depth: 1,
|
||||
locale: locale as never,
|
||||
})) as SettingsShape
|
||||
const settings = (preloaded ??
|
||||
(await payload.findGlobal({
|
||||
slug: settingsSlug as never,
|
||||
depth: 1,
|
||||
locale: locale as never,
|
||||
}))) as SettingsShape
|
||||
|
||||
const homepage =
|
||||
settings.homepage && typeof settings.homepage === 'object' ? settings.homepage : null
|
||||
@@ -64,7 +71,7 @@ export async function readSiteMetaConfig({
|
||||
try {
|
||||
const homeDoc = (await payload.findByID({
|
||||
id: homepage.id,
|
||||
collection: 'pages' as never,
|
||||
collection: pagesSlug as never,
|
||||
depth: 0,
|
||||
locale: 'all' as never,
|
||||
})) as { slug?: unknown }
|
||||
|
||||
Reference in New Issue
Block a user