From 9e5ad41e5c776c74a5135a535fa3d157b2f04407 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sun, 30 Apr 2023 13:19:35 +0200 Subject: [PATCH] Fixed sequential contents in the wrong order --- src/components/Markdown/Markdawn.tsx | 2 +- src/graphql/operations/getContentsFolder.graphql | 1 + src/pages/contents/[slug].tsx | 12 +++++++----- src/pages/contents/folder/[slug].tsx | 8 +++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/Markdown/Markdawn.tsx b/src/components/Markdown/Markdawn.tsx index 3e5401c..db81f3f 100644 --- a/src/components/Markdown/Markdawn.tsx +++ b/src/components/Markdown/Markdawn.tsx @@ -36,7 +36,7 @@ export const Markdawn = ({ className, text: rawText }: MarkdawnProps): JSX.Eleme const { showLightBox } = useAtomGetter(atoms.lightBox); /* eslint-disable no-irregular-whitespace */ - const text = `${preprocessMarkDawn(rawText, playerName)}\n + const text = `${preprocessMarkDawn(rawText, playerName)} ​`; /* eslint-enable no-irregular-whitespace */ diff --git a/src/graphql/operations/getContentsFolder.graphql b/src/graphql/operations/getContentsFolder.graphql index 4e06f5a..4b2cb0c 100644 --- a/src/graphql/operations/getContentsFolder.graphql +++ b/src/graphql/operations/getContentsFolder.graphql @@ -3,6 +3,7 @@ query getContentsFolder($slug: String, $language_code: String) { data { attributes { slug + sequence titles(pagination: { limit: -1 }) { id language { diff --git a/src/pages/contents/[slug].tsx b/src/pages/contents/[slug].tsx index 7ffb02c..db355ad 100644 --- a/src/pages/contents/[slug].tsx +++ b/src/pages/contents/[slug].tsx @@ -282,7 +282,7 @@ const Content = ({ content, ...otherProps }: Props): JSX.Element => { />, previousContent?.attributes && ( -
+ <>

{format("previous_content")}

{ : undefined } /> -
+ ), selectedTranslation?.text_set?.text && ( @@ -418,9 +418,11 @@ export const getStaticProps: GetStaticProps = async (context) => { const thumbnail = content.contents.data[0].attributes.thumbnail?.data?.attributes; - content.contents.data[0].attributes.folder?.data?.attributes?.contents?.data.sort((a, b) => - a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 - ); + if (content.contents.data[0].attributes.folder?.data?.attributes?.sequence === false) { + content.contents.data[0].attributes.folder.data.attributes.contents?.data.sort((a, b) => + a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 + ); + } const props: Props = { content: content.contents.data[0].attributes as ContentWithTranslations, diff --git a/src/pages/contents/folder/[slug].tsx b/src/pages/contents/folder/[slug].tsx index 5397d9b..caeab2f 100644 --- a/src/pages/contents/folder/[slug].tsx +++ b/src/pages/contents/folder/[slug].tsx @@ -222,9 +222,11 @@ export const getStaticProps: GetStaticProps = async (context) => { a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 ); - folder.contents?.data.sort((a, b) => - a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 - ); + if (!folder.sequence) { + folder.contents?.data.sort((a, b) => + a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 + ); + } const title = (() => { if (slug === "root") {