import AppLayout from "components/AppLayout"; import Switch from "components/Inputs/Switch"; import PanelHeader from "components/PanelComponents/PanelHeader"; import ContentPanel, { ContentPanelWidthSizes, } from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; import ThumbnailPreview from "components/PreviewCard"; import { GetPostsPreviewQuery } from "graphql/generated"; import { getReadySdk } from "graphql/sdk"; import { prettyDate, prettySlug } from "helpers/formatters"; import { AppStaticProps, getAppStaticProps } from "helpers/getAppStaticProps"; import { GetStaticPropsContext } from "next"; import { useState } from "react"; interface Props extends AppStaticProps { posts: Exclude["data"]; } export default function News(props: Props): JSX.Element { const { langui, posts } = props; const [keepInfoVisible, setKeepInfoVisible] = useState(true); posts .sort((a, b) => { const dateA = a.attributes?.date ? prettyDate(a.attributes.date) : "9999"; const dateB = b.attributes?.date ? prettyDate(b.attributes.date) : "9999"; return dateA.localeCompare(dateB); }) .reverse(); const subPanel = (

{"Always show info"}:

); const contentPanel = (
{posts.map((post) => ( <> {post.attributes && ( category.attributes?.short ?? "" )} thumbnailAspectRatio="3/2" keepInfoVisible={keepInfoVisible} metadata={{ release_date: post.attributes.date, position: "Top", }} /> )} ))}
); return ( ); } export async function getStaticProps( context: GetStaticPropsContext ): Promise<{ notFound: boolean } | { props: Props }> { const sdk = getReadySdk(); const posts = await sdk.getPostsPreview({ language_code: context.locale ?? "en", }); if (!posts.posts) return { notFound: true }; const props: Props = { ...(await getAppStaticProps(context)), posts: posts.posts.data, }; return { props: props, }; }