diff --git a/src/components/Content/ThumbnailHeader.tsx b/src/components/Content/ThumbnailHeader.tsx index 5ae6da6..b9bfd44 100644 --- a/src/components/Content/ThumbnailHeader.tsx +++ b/src/components/Content/ThumbnailHeader.tsx @@ -2,10 +2,11 @@ import { GetContentQuery, GetWebsiteInterfaceQuery, } from "graphql/operations-types"; -import { prettySlug } from "queries/helpers"; +import { prettyinlineTitle, prettySlug, slugify } from "queries/helpers"; import Button from "components/Button"; import Img, { ImageQuality } from "components/Img"; import InsetBox from "components/InsetBox"; +import Chip from "components/Chip"; export type ThumbnailHeaderProps = { content: { @@ -39,7 +40,18 @@ export default function ThumbnailHeader(
)} -
+
0 + ? prettyinlineTitle( + content.titles[0].pre_title, + content.titles[0].title, + content.titles[0].subtitle + ) + : prettySlug(content.slug) + )} + className="grid place-items-center text-center" + > {content.titles.length > 0 ? ( <>

{content.titles[0].pre_title}

@@ -54,22 +66,26 @@ export default function ThumbnailHeader(
{content.type && ( -
+

{langui.type}

- +
+ + {content.type.data.attributes.titles.length > 0 + ? content.type.data.attributes.titles[0].title + : prettySlug(content.type.data.attributes.slug)} + +
)} {content.categories.data.length > 0 && ( -
+

{langui.categories}

- {content.categories.data.map((category) => ( - - ))} +
+ {content.categories.data.map((category) => ( + {category.attributes.name} + ))} +
)}
diff --git a/src/components/Panels/MainPanel.tsx b/src/components/Panels/MainPanel.tsx index f1928fa..5ea88c6 100644 --- a/src/components/Panels/MainPanel.tsx +++ b/src/components/Panels/MainPanel.tsx @@ -117,6 +117,8 @@ export default function MainPanel(props: MainPanelProps): JSX.Element { onClick={() => appLayout.setMainPanelOpen(false)} /> + {/* + appLayout.setMainPanelOpen(false)} /> + + */} @@ -147,7 +151,7 @@ export default function MainPanel(props: MainPanelProps): JSX.Element { reduced={appLayout.mainPanelReduced && isDesktop} onClick={() => appLayout.setMainPanelOpen(false)} /> - + {/* appLayout.setMainPanelOpen(false)} /> + + */} appLayout.setMainPanelOpen(false)} /> + {/* + appLayout.setMainPanelOpen(false)} /> + + */} + )} + + + 0 + ? prettyinlineTitle( + content.titles[0].pre_title, + content.titles[0].title, + content.titles[0].subtitle + ) + : prettySlug(content.slug) + } + /> ); const contentPanel = ( diff --git a/src/pages/contents/index.tsx b/src/pages/contents/index.tsx index be8b767..77fe5ed 100644 --- a/src/pages/contents/index.tsx +++ b/src/pages/contents/index.tsx @@ -3,7 +3,10 @@ import SubPanel from "components/Panels/SubPanel"; import ContentPanel, { ContentPanelWidthSizes, } from "components/Panels/ContentPanel"; -import { GetContentsQuery } from "graphql/operations-types"; +import { + GetContentsQuery, + GetWebsiteInterfaceQuery, +} from "graphql/operations-types"; import { getContents } from "graphql/operations"; import PanelHeader from "components/PanelComponents/PanelHeader"; import AppLayout from "components/AppLayout"; @@ -12,6 +15,7 @@ import { prettyinlineTitle, prettySlug } from "queries/helpers"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; import Select from "components/Select"; import { useEffect, useState } from "react"; +import Chip from "components/Chip"; interface ContentsProps extends AppStaticProps { contents: GetContentsQuery["contents"]["data"]; @@ -25,11 +29,11 @@ export default function Contents(props: ContentsProps): JSX.Element { const [groupingMethod, setGroupingMethod] = useState(-1); const [groups, setGroups] = useState( - getGroups(groupingMethod, contents) + getGroups(langui, groupingMethod, contents) ); useEffect(() => { - setGroups(getGroups(groupingMethod, contents)); + setGroups(getGroups(langui, groupingMethod, contents)); }, [langui, groupingMethod, contents]); const subPanel = ( @@ -61,9 +65,14 @@ export default function Contents(props: ContentsProps): JSX.Element { {name && (

{name} + {`${items.length} ${ + items.length <= 1 + ? langui.result.toLowerCase() + : langui.results.toLowerCase() + }`}

)}
{ }; function getGroups( + langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"], groupByType: number, items: ContentsProps["contents"] ): GroupContentItems { @@ -150,11 +160,11 @@ function getGroups( typeGroup.set("Bakuken", []); typeGroup.set("YoRHa", []); typeGroup.set("YoRHa Boys", []); - typeGroup.set("No category", []); + typeGroup.set(langui.no_category, []); items.map((item) => { if (item.attributes.categories.data.length === 0) { - typeGroup.get("No category")?.push(item); + typeGroup.get(langui.no_category)?.push(item); } else { item.attributes.categories.data.map((category) => { typeGroup.get(category.attributes.name)?.push(item); diff --git a/src/pages/library/[slug].tsx b/src/pages/library/[slug].tsx index d37c98a..7fcd1fe 100644 --- a/src/pages/library/[slug].tsx +++ b/src/pages/library/[slug].tsx @@ -218,13 +218,11 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
{item.categories.data.length > 0 && ( -
+

{langui.categories}

-
+
{item.categories.data.map((category) => ( - - {category.attributes.short} - + {category.attributes.name} ))}
diff --git a/src/pages/library/index.tsx b/src/pages/library/index.tsx index ed121d9..37e6008 100644 --- a/src/pages/library/index.tsx +++ b/src/pages/library/index.tsx @@ -17,6 +17,7 @@ import { useEffect, useState } from "react"; import { convertPrice, prettyDate, prettyinlineTitle } from "queries/helpers"; import Switch from "components/Switch"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; +import Chip from "components/Chip"; interface LibraryProps extends AppStaticProps { items: GetLibraryItemsPreviewQuery["libraryItems"]["data"]; @@ -116,9 +117,14 @@ export default function Library(props: LibraryProps): JSX.Element { {name && (

{name} + {`${items.length} ${ + items.length <= 1 + ? langui.result.toLowerCase() + : langui.results.toLowerCase() + }`}

)}
{ if (item.attributes.categories.data.length === 0) { - typeGroup.get("No category")?.push(item); + typeGroup.get(langui.no_category)?.push(item); } else { item.attributes.categories.data.map((category) => { typeGroup.get(category.attributes.name)?.push(item); diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts index 6e30470..bbf5786 100644 --- a/src/queries/helpers.ts +++ b/src/queries/helpers.ts @@ -256,3 +256,20 @@ export function sortContent( return 0; }); } + +export function slugify(str: string): string { + return str + .replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, "a") + .replace(/[çÇ]/g, "c") + .replace(/[ðÐ]/g, "d") + .replace(/[ÈÉÊËéèêë]/g, "e") + .replace(/[ÏïÎîÍíÌì]/g, "i") + .replace(/[Ññ]/g, "n") + .replace(/[øØœŒÕõÔôÓóÒò]/g, "o") + .replace(/[ÜüÛûÚúÙù]/g, "u") + .replace(/[ŸÿÝý]/g, "y") + .replace(/[^a-z0-9- ]/gi, "") + .trim() + .replace(/ /gi, "-") + .toLowerCase(); +}