diff --git a/src/components/Post.tsx b/src/components/Post.tsx deleted file mode 100644 index f58e7c0..0000000 --- a/src/components/Post.tsx +++ /dev/null @@ -1,182 +0,0 @@ -import { GetPostQuery } from "graphql/generated"; -import useSmartLanguage from "hooks/useSmartLanguage"; -import { AppStaticProps } from "queries/getAppStaticProps"; -import { getStatusDescription, prettySlug } from "queries/helpers"; -import AppLayout from "./AppLayout"; -import Chip from "./Chip"; -import HorizontalLine from "./HorizontalLine"; -import Markdawn from "./Markdown/Markdawn"; -import TOC from "./Markdown/TOC"; -import ReturnButton, { ReturnButtonType } from "./PanelComponents/ReturnButton"; -import ContentPanel from "./Panels/ContentPanel"; -import SubPanel from "./Panels/SubPanel"; -import RecorderChip from "./RecorderChip"; -import ThumbnailHeader from "./ThumbnailHeader"; -import ToolTip from "./ToolTip"; - -interface Props { - post: Exclude< - Exclude< - GetPostQuery["posts"], - null | undefined - >["data"][number]["attributes"], - null | undefined - >; - langui: AppStaticProps["langui"]; - languages: AppStaticProps["languages"]; - currencies: AppStaticProps["currencies"]; - returnHref?: string; - returnTitle?: string | null | undefined; - displayCredits?: boolean; - displayToc?: boolean; - displayThumbnailHeader?: boolean; - displayTitle?: boolean; - displayLanguageSwitcher?: boolean; - prependBody?: JSX.Element; - appendBody?: JSX.Element; -} - -export default function Post(props: Props): JSX.Element { - const { - post, - langui, - languages, - returnHref, - returnTitle, - displayCredits, - displayToc, - displayThumbnailHeader, - displayLanguageSwitcher, - appendBody, - prependBody, - } = props; - const displayTitle = props.displayTitle ?? true; - - const [selectedTranslation, LanguageSwitcher] = useSmartLanguage({ - items: post.translations, - languages: languages, - languageExtractor: (item) => item?.language?.data?.attributes?.code, - }); - - const thumbnail = - selectedTranslation?.thumbnail?.data?.attributes ?? - post.thumbnail?.data?.attributes; - - const body = selectedTranslation?.body ?? ""; - const title = selectedTranslation?.title ?? prettySlug(post.slug); - const except = selectedTranslation?.excerpt ?? ""; - - const subPanel = - returnHref || returnTitle || displayCredits || displayToc ? ( - - {returnHref && returnTitle && ( - - )} - - {displayCredits && ( - <> - {selectedTranslation && ( - - {langui.status}: - - - {selectedTranslation.status} - - - )} - - {post.authors && post.authors.data.length > 0 && ( - - {"Authors"}: - - {post.authors.data.map((author) => ( - <> - {author.attributes && ( - - )} - > - ))} - - - )} - - - > - )} - - {displayToc && } - - ) : undefined; - - const contentPanel = ( - - {returnHref && returnTitle && ( - - )} - - {displayThumbnailHeader ? ( - <> - } - /> - - - > - ) : ( - <> - {displayLanguageSwitcher && ( - - - - )} - {displayTitle && ( - - {title} - - )} - > - )} - - {prependBody} - - {appendBody} - - ); - - return ( - - ); -} diff --git a/src/pages/about-us/accords-handbook.tsx b/src/pages/about-us/accords-handbook.tsx index 2faba56..f902502 100644 --- a/src/pages/about-us/accords-handbook.tsx +++ b/src/pages/about-us/accords-handbook.tsx @@ -1,20 +1,16 @@ -import Post from "components/Post"; -import { GetPostQuery } from "graphql/generated"; +import PostPage, { Post } from "components/PostPage"; 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"]; + post: Post; } export default function AccordsHandbook(props: Props): JSX.Element { const { post, langui, languages, currencies } = props; return ( - ["data"][number]["attributes"]; + post: Post; } export default function AboutUs(props: Props): JSX.Element { @@ -171,7 +167,7 @@ export default function AboutUs(props: Props): JSX.Element { ); return ( - ["data"][number]["attributes"]; + post: Post; } export default function SiteInformation(props: Props): JSX.Element { const { post, langui, languages, currencies } = props; return ( - ["data"][number]["attributes"]; + post: Post; } export default function SharingPolicy(props: Props): JSX.Element { const { post, langui, languages, currencies } = props; return ( - ["data"][number]["attributes"]; + post: Post; } export default function Home(props: Props): JSX.Element { const { post, langui, languages, currencies } = props; return ( - ["data"][number]["attributes"], - null | undefined - >; + post: Post; postId: Exclude< GetPostQuery["posts"], null | undefined @@ -25,7 +19,7 @@ interface Props extends AppStaticProps { export default function LibrarySlug(props: Props): JSX.Element { const { post, langui, languages, currencies } = props; return ( -
{langui.status}:
{"Authors"}: