-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demo Site: add footer to page (#3102)
- Loading branch information
1 parent
81791a1
commit 16f421f
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
demo/site/src/app/[domain]/[language]/[[...path]]/layout.tsx
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,39 @@ | ||
import { gql, previewParams } from "@comet/cms-site"; | ||
import { GQLLayoutQuery, GQLLayoutQueryVariables } from "@src/app/[domain]/[language]/[[...path]]/layout.generated"; | ||
import { Footer } from "@src/layout/footer/Footer"; | ||
import { footerFragment } from "@src/layout/footer/Footer.fragment"; | ||
import { createGraphQLFetch } from "@src/util/graphQLClient"; | ||
import type { Metadata } from "next"; | ||
import { PropsWithChildren } from "react"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Comet Starter", | ||
}; | ||
|
||
export default async function Layout({ | ||
children, | ||
params: { domain, language }, | ||
}: PropsWithChildren<{ params: { domain: string; language: string } }>) { | ||
const { previewData } = (await previewParams()) || { previewData: undefined }; | ||
const graphqlFetch = createGraphQLFetch(previewData); | ||
|
||
const { footer } = await graphqlFetch<GQLLayoutQuery, GQLLayoutQueryVariables>( | ||
gql` | ||
query Layout($domain: String!, $language: String!) { | ||
footer: footer(scope: { domain: $domain, language: $language }) { | ||
...Footer | ||
} | ||
} | ||
${footerFragment} | ||
`, | ||
{ domain, language }, | ||
); | ||
|
||
return ( | ||
<> | ||
{children} | ||
{footer && <Footer footer={footer} />} | ||
</> | ||
); | ||
} |