Fixed sequential contents in the wrong order

This commit is contained in:
DrMint 2023-04-30 13:19:35 +02:00
parent ca12dc2c29
commit 9e5ad41e5c
4 changed files with 14 additions and 9 deletions
src
components/Markdown
graphql/operations
pages/contents

@ -36,7 +36,7 @@ export const Markdawn = ({ className, text: rawText }: MarkdawnProps): JSX.Eleme
const { showLightBox } = useAtomGetter(atoms.lightBox); const { showLightBox } = useAtomGetter(atoms.lightBox);
/* eslint-disable no-irregular-whitespace */ /* eslint-disable no-irregular-whitespace */
const text = `${preprocessMarkDawn(rawText, playerName)}\n const text = `${preprocessMarkDawn(rawText, playerName)}
`; `;
/* eslint-enable no-irregular-whitespace */ /* eslint-enable no-irregular-whitespace */

@ -3,6 +3,7 @@ query getContentsFolder($slug: String, $language_code: String) {
data { data {
attributes { attributes {
slug slug
sequence
titles(pagination: { limit: -1 }) { titles(pagination: { limit: -1 }) {
id id
language { language {

@ -282,7 +282,7 @@ const Content = ({ content, ...otherProps }: Props): JSX.Element => {
/>, />,
previousContent?.attributes && ( previousContent?.attributes && (
<div className="mb-6 w-full"> <>
<h2 className="mb-4 text-center text-2xl">{format("previous_content")}</h2> <h2 className="mb-4 text-center text-2xl">{format("previous_content")}</h2>
<TranslatedPreviewLine <TranslatedPreviewLine
href={`/contents/${previousContent.attributes.slug}`} href={`/contents/${previousContent.attributes.slug}`}
@ -315,7 +315,7 @@ const Content = ({ content, ...otherProps }: Props): JSX.Element => {
: undefined : undefined
} }
/> />
</div> </>
), ),
selectedTranslation?.text_set?.text && ( selectedTranslation?.text_set?.text && (
@ -418,9 +418,11 @@ export const getStaticProps: GetStaticProps = async (context) => {
const thumbnail = content.contents.data[0].attributes.thumbnail?.data?.attributes; const thumbnail = content.contents.data[0].attributes.thumbnail?.data?.attributes;
content.contents.data[0].attributes.folder?.data?.attributes?.contents?.data.sort((a, b) => 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 a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0
); );
}
const props: Props = { const props: Props = {
content: content.contents.data[0].attributes as ContentWithTranslations, content: content.contents.data[0].attributes as ContentWithTranslations,

@ -222,9 +222,11 @@ export const getStaticProps: GetStaticProps = async (context) => {
a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0
); );
if (!folder.sequence) {
folder.contents?.data.sort((a, b) => folder.contents?.data.sort((a, b) =>
a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0
); );
}
const title = (() => { const title = (() => {
if (slug === "root") { if (slug === "root") {