accords-library.com/src/pages/about-us/sharing-policy.tsx

47 lines
1.3 KiB
TypeScript

import Post from "components/Post";
import { GetPostQuery } from "graphql/generated";
import { getReadySdk } from "graphql/sdk";
import { GetStaticPropsContext } from "next";
import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps";
interface Props extends AppStaticProps {
post: Exclude<
GetPostQuery["posts"],
null | undefined
>["data"][number]["attributes"];
}
export default function SharingPolicy(props: Props): JSX.Element {
const { post, langui, languages, currencies } = props;
return (
<Post
currencies={currencies}
languages={languages}
langui={langui}
post={post}
returnHref="/about-us/"
returnTitle={langui.about_us}
displayToc
displayLanguageSwitcher
/>
);
}
export async function getStaticProps(
context: GetStaticPropsContext
): Promise<{ notFound: boolean } | { props: Props }> {
const sdk = getReadySdk();
const slug = "sharing-policy";
const post = await sdk.getPost({
slug: slug,
language_code: context.locale ?? "en",
});
if (!post.posts) return { notFound: true };
const props: Props = {
...(await getAppStaticProps(context)),
post: post.posts.data[0].attributes,
};
return {
props: props,
};
}