Skip to content

Commit

Permalink
Demo Site: add footer to page (#3102)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelblum authored Jan 16, 2025
1 parent 81791a1 commit 16f421f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions demo/site/src/app/[domain]/[language]/[[...path]]/layout.tsx
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} />}
</>
);
}

0 comments on commit 16f421f

Please sign in to comment.