2022-05-08 10:21:29 +00:00
|
|
|
import PostPage from "components/PostPage";
|
2022-03-31 12:59:31 +00:00
|
|
|
import { getReadySdk } from "graphql/sdk";
|
2022-03-27 15:01:14 +00:00
|
|
|
import { GetStaticPropsContext } from "next";
|
2022-05-08 10:26:36 +00:00
|
|
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
2022-05-08 10:21:29 +00:00
|
|
|
import { Post } from "helpers/types";
|
2022-02-12 10:02:22 +00:00
|
|
|
|
2022-03-31 12:59:31 +00:00
|
|
|
interface Props extends AppStaticProps {
|
2022-05-07 09:19:28 +00:00
|
|
|
post: Post;
|
2022-03-12 12:26:41 +00:00
|
|
|
}
|
2022-02-12 10:02:22 +00:00
|
|
|
|
2022-03-31 12:59:31 +00:00
|
|
|
export default function Home(props: Props): JSX.Element {
|
2022-04-12 10:25:40 +00:00
|
|
|
const { post, langui, languages, currencies } = props;
|
|
|
|
return (
|
2022-05-07 09:19:28 +00:00
|
|
|
<PostPage
|
2022-04-12 10:25:40 +00:00
|
|
|
currencies={currencies}
|
|
|
|
languages={languages}
|
|
|
|
langui={langui}
|
|
|
|
post={post}
|
|
|
|
prependBody={
|
|
|
|
<div className="grid place-items-center place-content-center w-full gap-5 text-center">
|
|
|
|
<div className="[mask:url('/icons/accords.svg')] [mask-size:contain] [mask-repeat:no-repeat] [mask-position:center] w-32 aspect-square mobile:w-[50vw] bg-black" />
|
|
|
|
<h1 className="text-5xl mb-0">Accord’s Library</h1>
|
|
|
|
<h2 className="text-xl -mt-5">
|
|
|
|
Discover • Analyze • Translate • Archive
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
displayTitle={false}
|
|
|
|
displayLanguageSwitcher
|
|
|
|
/>
|
2022-02-15 14:50:51 +00:00
|
|
|
);
|
2022-01-01 02:31:55 +00:00
|
|
|
}
|
2022-02-12 10:02:22 +00:00
|
|
|
|
2022-03-27 15:01:14 +00:00
|
|
|
export async function getStaticProps(
|
|
|
|
context: GetStaticPropsContext
|
2022-03-31 12:59:31 +00:00
|
|
|
): Promise<{ notFound: boolean } | { props: Props }> {
|
|
|
|
const sdk = getReadySdk();
|
2022-03-20 12:21:30 +00:00
|
|
|
const slug = "home";
|
2022-03-31 12:59:31 +00:00
|
|
|
const post = await sdk.getPost({
|
|
|
|
slug: slug,
|
|
|
|
language_code: context.locale ?? "en",
|
|
|
|
});
|
2022-05-07 09:19:28 +00:00
|
|
|
if (!post.posts?.data[0].attributes) return { notFound: true };
|
2022-03-31 12:59:31 +00:00
|
|
|
const props: Props = {
|
2022-03-07 14:50:00 +00:00
|
|
|
...(await getAppStaticProps(context)),
|
2022-03-31 12:59:31 +00:00
|
|
|
post: post.posts.data[0].attributes,
|
2022-03-07 14:50:00 +00:00
|
|
|
};
|
|
|
|
return {
|
|
|
|
props: props,
|
|
|
|
};
|
2022-03-27 15:01:14 +00:00
|
|
|
}
|