diff --git a/src/pages/about-us/accords-handbook.tsx b/src/pages/about-us/accords-handbook.tsx index 43946a9..bdfa474 100644 --- a/src/pages/about-us/accords-handbook.tsx +++ b/src/pages/about-us/accords-handbook.tsx @@ -1,4 +1,5 @@ import AppLayout from "components/AppLayout"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import TOC from "components/Markdown/TOC"; import ReturnButton, { @@ -6,7 +7,7 @@ import ReturnButton, { } from "components/PanelComponents/ReturnButton"; import ContentPanel from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; -import { getPost } from "graphql/operations"; +import { getPost, getPostLanguages } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -15,12 +16,13 @@ import { prettySlug } from "queries/helpers"; interface AccordsHandbookProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; + locales: string[]; } export default function AccordsHandbook( props: AccordsHandbookProps ): JSX.Element { - const { langui, post } = props; + const { langui, post, locales } = props; const router = useRouter(); const subPanel = ( @@ -51,8 +53,15 @@ export default function AccordsHandbook( title={langui.about_us} className="mb-10" /> - {post.translations.length > 0 && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -72,14 +81,20 @@ export default function AccordsHandbook( } export const getStaticProps: GetStaticProps = async (context) => { + const slug = "accords-handbook"; const props: AccordsHandbookProps = { ...(await getAppStaticProps(context)), post: ( await getPost({ - slug: "accords-handbook", + slug: slug, language_code: context.locale || "en", }) ).posts.data[0].attributes, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, diff --git a/src/pages/about-us/legality.tsx b/src/pages/about-us/legality.tsx index d773386..f67a28a 100644 --- a/src/pages/about-us/legality.tsx +++ b/src/pages/about-us/legality.tsx @@ -1,4 +1,5 @@ import AppLayout from "components/AppLayout"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import TOC from "components/Markdown/TOC"; import ReturnButton, { @@ -6,7 +7,7 @@ import ReturnButton, { } from "components/PanelComponents/ReturnButton"; import ContentPanel from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; -import { getPost } from "graphql/operations"; +import { getPost, getPostLanguages } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -15,10 +16,11 @@ import { prettySlug } from "queries/helpers"; interface SiteInfoProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; + locales: string[]; } export default function SiteInformation(props: SiteInfoProps): JSX.Element { - const { langui, post } = props; + const { langui, post, locales } = props; const router = useRouter(); const subPanel = ( @@ -49,8 +51,15 @@ export default function SiteInformation(props: SiteInfoProps): JSX.Element { title={langui.about_us} className="mb-10" /> - {post.translations.length > 0 && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -70,14 +79,20 @@ export default function SiteInformation(props: SiteInfoProps): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { + const slug = "legality"; const props: SiteInfoProps = { ...(await getAppStaticProps(context)), post: ( await getPost({ - slug: "legality", + slug: slug, language_code: context.locale || "en", }) ).posts.data[0].attributes, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props, diff --git a/src/pages/about-us/sharing-policy.tsx b/src/pages/about-us/sharing-policy.tsx index aea24e4..f0a9a25 100644 --- a/src/pages/about-us/sharing-policy.tsx +++ b/src/pages/about-us/sharing-policy.tsx @@ -1,4 +1,5 @@ import AppLayout from "components/AppLayout"; +import LanguageSwitcher from "components/LanguageSwitcher"; import Markdawn from "components/Markdown/Markdawn"; import TOC from "components/Markdown/TOC"; import ReturnButton, { @@ -6,7 +7,7 @@ import ReturnButton, { } from "components/PanelComponents/ReturnButton"; import ContentPanel from "components/Panels/ContentPanel"; import SubPanel from "components/Panels/SubPanel"; -import { getPost } from "graphql/operations"; +import { getPost, getPostLanguages } from "graphql/operations"; import { GetPostQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; import { useRouter } from "next/router"; @@ -15,10 +16,11 @@ import { prettySlug } from "queries/helpers"; interface SharingPolicyProps extends AppStaticProps { post: GetPostQuery["posts"]["data"][number]["attributes"]; + locales: string[]; } export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { - const { langui, post } = props; + const { langui, post, locales } = props; const router = useRouter(); const subPanel = ( @@ -49,8 +51,15 @@ export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { title={langui.about_us} className="mb-10" /> - {post.translations.length > 0 && ( + {locales.includes(router.locale || "en") ? ( + ) : ( + )} ); @@ -70,6 +79,7 @@ export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { + const slug = "sharing-policy"; const props: SharingPolicyProps = { ...(await getAppStaticProps(context)), post: ( @@ -78,6 +88,11 @@ export const getStaticProps: GetStaticProps = async (context) => { language_code: context.locale || "en", }) ).posts.data[0].attributes, + locales: ( + await getPostLanguages({ slug: slug }) + ).posts.data[0].attributes.translations.map((translation) => { + return translation.language.data.attributes.code; + }), }; return { props: props,