From c6b6ec1479a362bb4e34820d200bd30cd806cd8e Mon Sep 17 00:00:00 2001 From: DrMint Date: Wed, 16 Feb 2022 19:44:05 +0100 Subject: [PATCH] More element are translation-ready --- next.config.js | 14 +- src/components/Content/ThumbnailHeader.tsx | 6 +- .../Library/LibraryContentPreview.tsx | 38 +++- src/components/Panels/MainPanel.tsx | 8 +- src/graphql/operation.graphql | 194 +++++++++--------- src/graphql/operations-types.ts | 101 ++++----- src/pages/about-us/index.tsx | 4 +- src/pages/archives/index.tsx | 4 +- src/pages/chronicles/index.tsx | 6 +- src/pages/gallery/index.tsx | 2 +- src/pages/hubs/index.tsx | 48 ----- src/pages/index.tsx | 3 +- src/pages/library/content/[slug]/index.tsx | 19 +- src/pages/library/content/[slug]/read.tsx | 2 +- src/pages/library/content/index.tsx | 14 +- src/pages/library/index.tsx | 12 +- src/pages/library/items/[slug].tsx | 5 +- src/pages/library/items/index.tsx | 6 +- src/pages/merch/index.tsx | 4 +- src/pages/news/index.tsx | 4 +- src/pages/wiki/index.tsx | 6 +- 21 files changed, 252 insertions(+), 248 deletions(-) delete mode 100644 src/pages/hubs/index.tsx diff --git a/next.config.js b/next.config.js index 8f5d375..3774e82 100644 --- a/next.config.js +++ b/next.config.js @@ -2,19 +2,19 @@ module.exports = { reactStrictMode: true, i18n: { - locales: ['en', 'fr', 'ja', 'es'], - defaultLocale: 'en', + locales: ["en", "fr", "ja", "es", "xx"], + defaultLocale: "en", }, images: { - domains: ['strapi.accords-library.com'], + domains: ["strapi.accords-library.com"], }, async redirects() { return [ { - source: '/discord', - destination: 'https://discord.com/invite/5mcXcRAczj', + source: "/discord", + destination: "https://discord.com/invite/5mcXcRAczj", permanent: false, }, - ] + ]; }, -} +}; diff --git a/src/components/Content/ThumbnailHeader.tsx b/src/components/Content/ThumbnailHeader.tsx index 492830b..898d0b6 100644 --- a/src/components/Content/ThumbnailHeader.tsx +++ b/src/components/Content/ThumbnailHeader.tsx @@ -56,7 +56,11 @@ export default function ThumbnailHeader( {content.type ? (

{langui.global_type}

- +
) : ( "" diff --git a/src/components/Library/LibraryContentPreview.tsx b/src/components/Library/LibraryContentPreview.tsx index c273a32..a38415a 100644 --- a/src/components/Library/LibraryContentPreview.tsx +++ b/src/components/Library/LibraryContentPreview.tsx @@ -2,12 +2,15 @@ import Link from "next/link"; import { GetContentsQuery } from "graphql/operations-types"; import { getAssetURL, prettySlug } from "queries/helpers"; import Image from "next/image"; +import Chip from "components/Chip"; export type LibraryContentPreviewProps = { item: { slug: GetContentsQuery["contents"]["data"][number]["attributes"]["slug"]; thumbnail: GetContentsQuery["contents"]["data"][number]["attributes"]["thumbnail"]; titles: GetContentsQuery["contents"]["data"][number]["attributes"]["titles"]; + categories: GetContentsQuery["contents"]["data"][number]["attributes"]["categories"]; + type: GetContentsQuery["contents"]["data"][number]["attributes"]["type"]; }; }; @@ -21,6 +24,7 @@ export default function LibraryContentPreview(
{item.thumbnail.data ? ( {item.thumbnail.data.attributes.alternativeText}
)} -
+
- {item.titles.length > 0 ? ( - <> -

{item.titles[0].pre_title}

-

{item.titles[0].title}

-

{item.titles[0].subtitle}

- - ) : ( -

{prettySlug(item.slug)}

- )} + {item.titles.length > 0 ? ( + <> +

{item.titles[0].pre_title}

+

{item.titles[0].title}

+

{item.titles[0].subtitle}

+ + ) : ( +

{prettySlug(item.slug)}

+ )} +
+
+ {item.categories.data.map((category) => ( + + {category.attributes.short} + + ))} +
+
+ {item.type ? ( + {item.type.data.attributes.titles.length > 0 ? item.type.data.attributes.titles[0].title : prettySlug(item.type.data.attributes.slug)} + ) : ( + "" + )}
diff --git a/src/components/Panels/MainPanel.tsx b/src/components/Panels/MainPanel.tsx index ebbe3e4..40d78c5 100644 --- a/src/components/Panels/MainPanel.tsx +++ b/src/components/Panels/MainPanel.tsx @@ -51,15 +51,15 @@ export default function MainPanel(props: MainPanelProps): JSX.Element { diff --git a/src/graphql/operation.graphql b/src/graphql/operation.graphql index b23d660..98739bb 100644 --- a/src/graphql/operation.graphql +++ b/src/graphql/operation.graphql @@ -4,12 +4,7 @@ query getWebsiteInterface($language_code: String) { attributes { main_library main_library_description - main_hub - main_hub_description - main_chronology - main_chronology_description main_news - main_data main_merch main_gallery main_archives @@ -39,13 +34,6 @@ query getWebsiteInterface($language_code: String) { global_price library_item_physical_size library_item_type_information - chronology_description - chronology_timelines - chronology_timelines_description - chronology_overview - chronology_overview_description - chronology_walkthrough - chronology_walkthrough_description library_item_front_matter library_item_back_matter library_item_type_textual @@ -64,6 +52,21 @@ query getWebsiteInterface($language_code: String) { global_hardcover global_left_to_right global_right_to_left + main_wiki + main_wiki_description + main_chronicles + main_chronicles_description + library_items + library_items_description + library_content + library_content_description + wiki_description + news_description + chronicles_description + gallery_description + archives_description + about_us_description + merch_description } } } @@ -479,93 +482,92 @@ query getContentsSlugs { } query getContents($language_code: String) { - contents(pagination: { limit: -1 }) { - data { + contents(pagination: { limit: -1 }) { + data { id - attributes { - slug - titles(filters: { language: { code: { eq: $language_code } } }) { - pre_title - title - subtitle - } - categories { - data { - id - attributes { - short - } - } - } - type { - data { - attributes { - slug - titles(filters: { language: { code: { eq: $language_code } } }) { - title - } - } - } - } - ranged_contents { - data { - id - attributes { - slug - scan_set { - id - } - library_item { - data { - attributes { - slug - title - subtitle - thumbnail { - data { - attributes { - name - alternativeText - caption - width - height - url - } - } - } - } - } - } - } - } - } - text_set { - id - } - video_set { - id - } - audio_set { - id - } - thumbnail { - data { - attributes { - name - alternativeText - caption - width - height - url - } - } - } - } - } - } + attributes { + slug + titles(filters: { language: { code: { eq: $language_code } } }) { + pre_title + title + subtitle + } + categories { + data { + id + attributes { + short + } + } + } + type { + data { + attributes { + slug + titles(filters: { language: { code: { eq: $language_code } } }) { + title + } + } + } + } + ranged_contents { + data { + id + attributes { + slug + scan_set { + id + } + library_item { + data { + attributes { + slug + title + subtitle + thumbnail { + data { + attributes { + name + alternativeText + caption + width + height + url + } + } + } + } + } + } + } + } + } + text_set { + id + } + video_set { + id + } + audio_set { + id + } + thumbnail { + data { + attributes { + name + alternativeText + caption + width + height + url + } + } + } + } + } + } } - query getContent($slug: String, $language_code: String) { contents(filters: { slug: { eq: $slug } }) { data { diff --git a/src/graphql/operations-types.ts b/src/graphql/operations-types.ts index f963b98..5f9206f 100644 --- a/src/graphql/operations-types.ts +++ b/src/graphql/operations-types.ts @@ -78,12 +78,7 @@ export type GetWebsiteInterfaceQuery = { __typename: "WebsiteInterface"; main_library: string; main_library_description: string; - main_hub: string; - main_hub_description: string; - main_chronology: string; - main_chronology_description: string; main_news: string; - main_data: string; main_merch: string; main_gallery: string; main_archives: string; @@ -113,13 +108,6 @@ export type GetWebsiteInterfaceQuery = { global_price: string; library_item_physical_size: string; library_item_type_information: string; - chronology_description: string; - chronology_timelines: string; - chronology_timelines_description: string; - chronology_overview: string; - chronology_overview_description: string; - chronology_walkthrough: string; - chronology_walkthrough_description: string; library_item_front_matter: string; library_item_back_matter: string; library_item_type_textual: string; @@ -138,6 +126,21 @@ export type GetWebsiteInterfaceQuery = { global_hardcover: string; global_left_to_right: string; global_right_to_left: string; + main_wiki: string; + main_wiki_description: string; + main_chronicles: string; + main_chronicles_description: string; + library_items: string; + library_items_description: string; + library_content: string; + library_content_description: string; + wiki_description: string; + news_description: string; + chronicles_description: string; + gallery_description: string; + archives_description: string; + about_us_description: string; + merch_description: string; }; }>; }; @@ -689,18 +692,18 @@ export type GetContentsQuery = { slug: string; titles: Array<{ __typename: "ComponentTranslationsTitle"; - pre_title: string ; + pre_title: string; title: string; - subtitle: string ; - } > ; + subtitle: string; + }>; categories: { __typename: "CategoryRelationResponseCollection"; data: Array<{ __typename: "CategoryEntity"; - id: string ; - attributes: { __typename: "Category"; short: string } ; + id: string; + attributes: { __typename: "Category"; short: string }; }>; - } ; + }; type: { __typename: "ContentTypeEntityResponse"; data: { @@ -711,22 +714,22 @@ export type GetContentsQuery = { titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; title: string; - } > ; - } ; - } ; - } ; + }>; + }; + }; + }; ranged_contents: { __typename: "RangedContentRelationResponseCollection"; data: Array<{ __typename: "RangedContentEntity"; - id: string ; + id: string; attributes: { __typename: "RangedContent"; slug: string; scan_set: Array<{ __typename: "ComponentSetsScanSet"; id: string; - } > ; + }>; library_item: { __typename: "LibraryItemEntityResponse"; data: { @@ -735,7 +738,7 @@ export type GetContentsQuery = { __typename: "LibraryItem"; slug: string; title: string; - subtitle: string ; + subtitle: string; thumbnail: { __typename: "UploadFileEntityResponse"; data: { @@ -743,32 +746,32 @@ export type GetContentsQuery = { attributes: { __typename: "UploadFile"; name: string; - alternativeText: string ; - caption: string ; - width: number ; - height: number ; + alternativeText: string; + caption: string; + width: number; + height: number; url: string; - } ; - } ; - } ; - } ; - } ; - } ; - } ; + }; + }; + }; + }; + }; + }; + }; }>; - } ; + }; text_set: Array<{ __typename: "ComponentSetsTextSet"; id: string; - } > ; + }>; video_set: Array<{ __typename: "ComponentSetsVideoSet"; id: string; - } > ; + }>; audio_set: Array<{ __typename: "ComponentSetsAudioSet"; id: string; - } > ; + }>; thumbnail: { __typename: "UploadFileEntityResponse"; data: { @@ -776,17 +779,17 @@ export type GetContentsQuery = { attributes: { __typename: "UploadFile"; name: string; - alternativeText: string ; - caption: string ; - width: number ; - height: number ; + alternativeText: string; + caption: string; + width: number; + height: number; url: string; - } ; - } ; - } ; - } ; + }; + }; + }; + }; }>; - } ; + }; }; export type GetContentQuery = { diff --git a/src/pages/about-us/index.tsx b/src/pages/about-us/index.tsx index b242500..0537f28 100644 --- a/src/pages/about-us/index.tsx +++ b/src/pages/about-us/index.tsx @@ -16,11 +16,11 @@ export default function AboutUs(props: AboutUsProps): JSX.Element { ); - return ; + return ; } export const getStaticProps: GetStaticProps = async (context) => { diff --git a/src/pages/archives/index.tsx b/src/pages/archives/index.tsx index f6a34d1..ec4b32b 100644 --- a/src/pages/archives/index.tsx +++ b/src/pages/archives/index.tsx @@ -16,11 +16,11 @@ export default function Archives(props: ArchivesProps): JSX.Element { ); - return ; + return ; } export const getStaticProps: GetStaticProps = async (context) => { diff --git a/src/pages/chronicles/index.tsx b/src/pages/chronicles/index.tsx index 46eaf40..dc9da8b 100644 --- a/src/pages/chronicles/index.tsx +++ b/src/pages/chronicles/index.tsx @@ -15,12 +15,12 @@ export default function Chronicles(props: ChroniclesProps): JSX.Element { ); - return ; + return ; } export const getStaticProps: GetStaticProps = async (context) => { diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 60e8e50..6298749 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -17,7 +17,7 @@ export default function Gallery(props: GalleryProps): JSX.Element { ); return ( - + ); } diff --git a/src/pages/hubs/index.tsx b/src/pages/hubs/index.tsx deleted file mode 100644 index d146c75..0000000 --- a/src/pages/hubs/index.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import SubPanel from "components/Panels/SubPanel"; -import PanelHeader from "components/PanelComponents/PanelHeader"; -import { GetWebsiteInterfaceQuery } from "graphql/operations-types"; -import { GetStaticProps } from "next"; -import { getWebsiteInterface } from "graphql/operations"; -import ContentPanel from "components/Panels/ContentPanel"; -import AppLayout from "components/AppLayout"; - -type HubsProps = { - langui: GetWebsiteInterfaceQuery; -}; - -export default function Hubs(props: HubsProps): JSX.Element { - const langui = props.langui.websiteInterfaces.data[0].attributes; - const subPanel = ( - - - - ); - const contentPanel = Hello; - - return ( - - ); -} - -export const getStaticProps: GetStaticProps = async (context) => { - if (context.locale) { - const props: HubsProps = { - langui: await getWebsiteInterface({ - language_code: context.locale, - }), - }; - return { - props: props, - }; - } - return { props: {} }; -}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 1a84cc7..2acd685 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -3,7 +3,6 @@ import ContentPanel from "components/Panels/ContentPanel"; import { getWebsiteInterface } from "graphql/operations"; import { GetWebsiteInterfaceQuery } from "graphql/operations-types"; import { GetStaticProps } from "next"; -import Head from "next/head"; type HomeProps = { langui: GetWebsiteInterfaceQuery; }; @@ -137,7 +136,7 @@ export default function Home(props: HomeProps): JSX.Element { return ( <> - + ); } diff --git a/src/pages/library/content/[slug]/index.tsx b/src/pages/library/content/[slug]/index.tsx index ab3ec95..cd78005 100644 --- a/src/pages/library/content/[slug]/index.tsx +++ b/src/pages/library/content/[slug]/index.tsx @@ -13,6 +13,8 @@ import Button from "components/Button"; import HorizontalLine from "components/HorizontalLine"; import ThumbnailHeader from "components/Content/ThumbnailHeader"; import AppLayout from "components/AppLayout"; +import SubPanel from "components/Panels/SubPanel"; +import ReturnButton from "components/PanelComponents/ReturnButton"; type ContentIndexProps = { content: GetContentQuery; @@ -22,6 +24,16 @@ type ContentIndexProps = { export default function ContentIndex(props: ContentIndexProps): JSX.Element { const content = props.content.contents.data[0].attributes; const langui = props.langui.websiteInterfaces.data[0].attributes; + const subPanel = ( + + + + + ); const contentPanel = (
@@ -57,7 +69,12 @@ export default function ContentIndex(props: ContentIndexProps): JSX.Element { ); return ( - + ); } diff --git a/src/pages/library/content/[slug]/read.tsx b/src/pages/library/content/[slug]/read.tsx index 9ad8dbe..907afc4 100644 --- a/src/pages/library/content/[slug]/read.tsx +++ b/src/pages/library/content/[slug]/read.tsx @@ -57,7 +57,7 @@ export default function ContentRead(props: ContentReadProps): JSX.Element { return ( { + const titleA = a.attributes.titles.length > 0 ? prettyinlineTitle(a.attributes.titles[0].pre_title, a.attributes.titles[0].title, a.attributes.titles[0].subtitle) : a.attributes.slug + const titleB = b.attributes.titles.length > 0 ? prettyinlineTitle(b.attributes.titles[0].pre_title, b.attributes.titles[0].title, b.attributes.titles[0].subtitle) : b.attributes.slug + return titleA.localeCompare(titleB); + }); + const subPanel = ( ); @@ -47,7 +55,7 @@ export default function Library(props: LibraryProps): JSX.Element { ); return ( ); - return ; + return ; } export const getStaticProps: GetStaticProps = async (context) => { diff --git a/src/pages/library/items/[slug].tsx b/src/pages/library/items/[slug].tsx index ab68a15..c398c1d 100644 --- a/src/pages/library/items/[slug].tsx +++ b/src/pages/library/items/[slug].tsx @@ -43,7 +43,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { @@ -493,6 +493,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { ); + // Sort content by range item.contents.data.sort((a, b) => { if ( a.attributes.range[0].__typename === "ComponentRangePageRange" && @@ -508,7 +509,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { return ( ); @@ -50,7 +50,7 @@ export default function Library(props: LibraryProps): JSX.Element { ); return ( ); - return ; + return ; } export const getStaticProps: GetStaticProps = async (context) => { diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx index be7932a..08ad1d3 100644 --- a/src/pages/news/index.tsx +++ b/src/pages/news/index.tsx @@ -16,12 +16,12 @@ export default function News(props: NewsProps): JSX.Element { ); - return ; + return ; } export const getStaticProps: GetStaticProps = async (context) => { diff --git a/src/pages/wiki/index.tsx b/src/pages/wiki/index.tsx index 0377db0..bf2b5f6 100644 --- a/src/pages/wiki/index.tsx +++ b/src/pages/wiki/index.tsx @@ -16,8 +16,8 @@ export default function Hubs(props: WikiProps): JSX.Element { ); @@ -25,7 +25,7 @@ export default function Hubs(props: WikiProps): JSX.Element { return (