Update to use payload for landing page
This commit is contained in:
24
apps/next/src/lib/payload/get-landing-page-content.ts
Normal file
24
apps/next/src/lib/payload/get-landing-page-content.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { LandingPageContent } from '@/components/landing/content';
|
||||
import { cache } from 'react';
|
||||
import {
|
||||
defaultLandingPageContent,
|
||||
mergeLandingPageContent,
|
||||
} from '@/components/landing/content';
|
||||
|
||||
import { getPayloadClient } from './get-payload';
|
||||
|
||||
export const getLandingPageContent = cache(
|
||||
async (): Promise<LandingPageContent> => {
|
||||
const payload = await getPayloadClient();
|
||||
const landingPage = await (
|
||||
payload as {
|
||||
findGlobal: (args: { slug: string }) => Promise<unknown>;
|
||||
}
|
||||
).findGlobal({ slug: 'landing-page' });
|
||||
|
||||
return mergeLandingPageContent(
|
||||
(landingPage as Partial<LandingPageContent> | null | undefined) ??
|
||||
defaultLandingPageContent,
|
||||
);
|
||||
},
|
||||
);
|
||||
7
apps/next/src/lib/payload/get-payload.ts
Normal file
7
apps/next/src/lib/payload/get-payload.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { cache } from 'react';
|
||||
import config from '@payload-config';
|
||||
import { getPayload } from 'payload';
|
||||
|
||||
export const getPayloadClient = cache(async () => {
|
||||
return await getPayload({ config });
|
||||
});
|
||||
Reference in New Issue
Block a user