From 75da36621620f1b92f47c7c78539cc66c9eb8416 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sat, 12 Feb 2022 11:02:22 +0100 Subject: [PATCH] Added support for UI translation and other fields --- src/components/Content/ThumbnailHeader.tsx | 20 +- .../Library/LibraryItemComponent.tsx | 2 +- .../PanelComponents/ReturnButton.tsx | 4 +- src/components/Panels/MainPanel.tsx | 56 +++- src/graphql/operation.graphql | 113 ++++++- src/graphql/operations-types.ts | 267 ++++++++++----- src/graphql/operations.ts | 9 + src/graphql/schema.graphql | 313 +++++++++++++++--- src/pages/404.tsx | 26 +- src/pages/_app.tsx | 1 - src/pages/chronology/index.tsx | 42 ++- src/pages/chronology/overview.tsx | 37 ++- src/pages/content/[slug]/index.tsx | 39 ++- src/pages/content/[slug]/read.tsx | 45 ++- src/pages/gallery/index.tsx | 28 +- src/pages/index.tsx | 29 +- src/pages/library/[slug].tsx | 211 ++++++++---- src/pages/library/index.tsx | 42 ++- src/queries/helpers.ts | 7 +- 19 files changed, 990 insertions(+), 301 deletions(-) diff --git a/src/components/Content/ThumbnailHeader.tsx b/src/components/Content/ThumbnailHeader.tsx index 95893ea..fa7ec88 100644 --- a/src/components/Content/ThumbnailHeader.tsx +++ b/src/components/Content/ThumbnailHeader.tsx @@ -21,13 +21,17 @@ export default function ThumbnailHeader( <>
- {content.thumbnail.data.attributes.alternativeText} + {content.thumbnail.data ? ( + {content.thumbnail.data.attributes.alternativeText} + ) : ( +
+ )}

{content.titles[0].pre_title}

@@ -40,7 +44,7 @@ export default function ThumbnailHeader( {content.type ? (

Type

- +
) : ( "" diff --git a/src/components/Library/LibraryItemComponent.tsx b/src/components/Library/LibraryItemComponent.tsx index 3129cfa..38d9549 100644 --- a/src/components/Library/LibraryItemComponent.tsx +++ b/src/components/Library/LibraryItemComponent.tsx @@ -32,7 +32,7 @@ export default function LibraryItemComponent( ) : (
)} -
+

{item.title}

{item.subtitle}

diff --git a/src/components/PanelComponents/ReturnButton.tsx b/src/components/PanelComponents/ReturnButton.tsx index 18921ae..a2593c1 100644 --- a/src/components/PanelComponents/ReturnButton.tsx +++ b/src/components/PanelComponents/ReturnButton.tsx @@ -1,10 +1,12 @@ import Button from "components/Button"; +import { GetWebsiteInterfaceQuery } from "graphql/operations-types"; type ReturnButtonProps = { href: string; title: string; + langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"]; }; export default function ReturnButton(props: ReturnButtonProps): JSX.Element { - return ; + return ; } diff --git a/src/components/Panels/MainPanel.tsx b/src/components/Panels/MainPanel.tsx index 3943ed9..c30c6f2 100644 --- a/src/components/Panels/MainPanel.tsx +++ b/src/components/Panels/MainPanel.tsx @@ -4,8 +4,15 @@ import SVG from "components/SVG"; import { useRouter } from "next/router"; import Button from "components/Button"; import HorizontalLine from "components/HorizontalLine"; +import { GetWebsiteInterfaceQuery } from "graphql/operations-types"; +import Markdown from "markdown-to-jsx"; -export default function MainPanel(): JSX.Element { +type Props = { + langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"]; +}; + +export default function MainPanel(props: Props): JSX.Element { + const langui = props.langui; const router = useRouter(); return (
@@ -37,39 +44,50 @@ export default function MainPanel(): JSX.Element { - - - - - + + + + + +

- This website’s content is made available under{" "} - CC-BY-SA{" "} - unless otherwise noted. + {langui.main_licensing ? ( + {langui.main_licensing} + ) : ( + "" + )}

- Accord’s Library is not affiliated with or endorsed by SQUARE - ENIX CO. LTD. All game assets and promotional materials belongs to - © SQUARE ENIX CO. LTD. + {langui.main_copyright ? ( + {langui.main_copyright} + ) : ( + "" + )}

; +}>; + +export type GetWebsiteInterfaceQuery = { + __typename: "Query"; + websiteInterfaces: { + __typename: "WebsiteInterfaceEntityResponseCollection"; + data: Array<{ + __typename: "WebsiteInterfaceEntity"; + attributes: { + __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; + main_about_us: string; + main_licensing: string; + main_copyright: string; + library_description: string; + library_item_summary: string; + library_item_gallery: string; + library_item_details: string; + library_item_subitems: string; + library_item_variants: string; + library_item_content: string; + global_return_label: string; + global_subitem_of: string; + global_type: string; + global_width: string; + global_height: string; + global_thickness: string; + global_binding: string; + global_language: string; + global_languages: string; + global_page: string; + global_pages: string; + global_page_order: string; + global_release_date: string; + 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; + }; + }>; + }; +}; + export type GetErasQueryVariables = Exact<{ language_code: InputMaybe; }>; @@ -304,6 +364,10 @@ export type GetLibraryItemQuery = { attributes: { __typename: "TextualSubtype"; slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; }; }; }; @@ -389,6 +453,10 @@ export type GetLibraryItemQuery = { attributes: { __typename: "AudioSubtype"; slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; }; }; }; @@ -404,19 +472,6 @@ export type GetLibraryItemQuery = { }>; }; } - | { - __typename: "ComponentMetadataMerch"; - merch_item: { - __typename: "MerchItemEntityResponse"; - data: { - __typename: "MerchItemEntity"; - attributes: { - __typename: "MerchItem"; - slug: string; - }; - }; - }; - } | { __typename: "ComponentMetadataOther"; subtype: { @@ -426,6 +481,10 @@ export type GetLibraryItemQuery = { attributes: { __typename: "OtherSubtype"; slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; }; }; }; @@ -473,6 +532,34 @@ export type GetLibraryItemQuery = { }; }>; }; + submerchs: { + __typename: "MerchItemRelationResponseCollection"; + data: Array<{ + __typename: "MerchItemEntity"; + id: string; + attributes: { + __typename: "MerchItem"; + slug: string; + title: string; + subtitle: string; + thumbnail: { + __typename: "UploadFileEntityResponse"; + data: { + __typename: "UploadFileEntity"; + attributes: { + __typename: "UploadFile"; + name: string; + alternativeText: string; + caption: string; + width: number; + height: number; + url: string; + }; + }; + }; + }; + }>; + }; contents: { __typename: "RangedContentRelationResponseCollection"; data: Array<{ @@ -524,6 +611,10 @@ export type GetLibraryItemQuery = { attributes: { __typename: "ContentType"; slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; }; }; }; @@ -605,7 +696,14 @@ export type GetContentQuery = { __typename: "ContentTypeEntityResponse"; data: { __typename: "ContentTypeEntity"; - attributes: { __typename: "ContentType"; slug: string }; + attributes: { + __typename: "ContentType"; + slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; + }; }; }; ranged_contents: { @@ -698,41 +796,48 @@ export type GetContentTextQuery = { 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 ; + id: string; attributes: { __typename: "Category"; name: string; short: string; - } ; + }; }>; - } ; + }; type: { __typename: "ContentTypeEntityResponse"; data: { __typename: "ContentTypeEntity"; - attributes: { __typename: "ContentType"; slug: string } ; - } ; - } ; + attributes: { + __typename: "ContentType"; + slug: string; + 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: { @@ -741,7 +846,7 @@ export type GetContentTextQuery = { __typename: "LibraryItem"; slug: string; title: string; - subtitle: string ; + subtitle: string; thumbnail: { __typename: "UploadFileEntityResponse"; data: { @@ -749,32 +854,32 @@ export type GetContentTextQuery = { 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"; status: Enum_Componentsetstextset_Status; - text: string ; - notes: string ; + text: string; + notes: string; source_language: { __typename: "LanguageEntityResponse"; data: { __typename: "LanguageEntity"; - attributes: { __typename: "Language"; name: string } ; - } ; - } ; + attributes: { __typename: "Language"; name: string }; + }; + }; transcribers: { __typename: "RecorderRelationResponseCollection"; data: Array<{ @@ -791,17 +896,17 @@ export type GetContentTextQuery = { attributes: { __typename: "UploadFile"; name: string; - alternativeText: string ; - caption: string ; - width: number ; - height: number ; + alternativeText: string; + caption: string; + width: number; + height: number; url: string; - } ; - } ; - } ; - } ; + }; + }; + }; + }; }>; - } ; + }; translators: { __typename: "RecorderRelationResponseCollection"; data: Array<{ @@ -818,17 +923,17 @@ export type GetContentTextQuery = { attributes: { __typename: "UploadFile"; name: string; - alternativeText: string ; - caption: string ; - width: number ; - height: number ; + alternativeText: string; + caption: string; + width: number; + height: number; url: string; - } ; - } ; - } ; - } ; + }; + }; + }; + }; }>; - } ; + }; proofreaders: { __typename: "RecorderRelationResponseCollection"; data: Array<{ @@ -845,18 +950,18 @@ export type GetContentTextQuery = { attributes: { __typename: "UploadFile"; name: string; - alternativeText: string ; - caption: string ; - width: number ; - height: number ; + alternativeText: string; + caption: string; + width: number; + height: number; url: string; - } ; - } ; - } ; - } ; + }; + }; + }; + }; }>; - } ; - } > ; + }; + }>; thumbnail: { __typename: "UploadFileEntityResponse"; data: { @@ -864,15 +969,15 @@ export type GetContentTextQuery = { attributes: { __typename: "UploadFile"; name: string; - alternativeText: string ; - caption: string ; - width: number ; - height: number ; + alternativeText: string; + caption: string; + width: number; + height: number; url: string; - } ; - } ; - } ; - } ; + }; + }; + }; + }; }>; - } ; + }; }; diff --git a/src/graphql/operations.ts b/src/graphql/operations.ts index a088cc4..615bedf 100644 --- a/src/graphql/operations.ts +++ b/src/graphql/operations.ts @@ -17,6 +17,8 @@ import { GetLibraryItemsPreviewQueryVariables, GetLibraryItemsSlugsQuery, GetLibraryItemsSlugsQueryVariables, + GetWebsiteInterfaceQuery, + GetWebsiteInterfaceQueryVariables, } from "graphql/operations-types"; const graphQL = async (query: string, variables?: string) => { @@ -50,6 +52,13 @@ function getQueryFromOperations(queryName: string): string { return lines.slice(startingIndex, endingIndex).join("\n"); } +export async function getWebsiteInterface( + variables: GetWebsiteInterfaceQueryVariables +): Promise { + const query = getQueryFromOperations("getWebsiteInterface"); + return await graphQL(query, JSON.stringify(variables)); +} + export async function getEras( variables: GetErasQueryVariables ): Promise { diff --git a/src/graphql/schema.graphql b/src/graphql/schema.graphql index b136f8c..2f6e33f 100644 --- a/src/graphql/schema.graphql +++ b/src/graphql/schema.graphql @@ -995,6 +995,26 @@ type ComponentTranslationsScanSet { credits: ComponentBasicsCredits! } +input ComponentTranslationsSimpleTitleFiltersInput { + language: LanguageFiltersInput + title: StringFilterInput + and: [ComponentTranslationsSimpleTitleFiltersInput] + or: [ComponentTranslationsSimpleTitleFiltersInput] + not: ComponentTranslationsSimpleTitleFiltersInput +} + +input ComponentTranslationsSimpleTitleInput { + id: ID + language: ID + title: String +} + +type ComponentTranslationsSimpleTitle { + id: ID! + language: LanguageEntityResponse + title: String! +} + enum ENUM_COMPONENTTRANSLATIONSTEXTSET_STATUS { Incomplete Draft @@ -1225,10 +1245,16 @@ input AudioSubtypeFiltersInput { input AudioSubtypeInput { slug: String + titles: [ComponentTranslationsSimpleTitleInput] } type AudioSubtype { slug: String! + titles( + filters: ComponentTranslationsSimpleTitleFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): [ComponentTranslationsSimpleTitle] createdAt: DateTime updatedAt: DateTime } @@ -1481,10 +1507,16 @@ input ContentTypeFiltersInput { input ContentTypeInput { slug: String + titles: [ComponentTranslationsSimpleTitleInput] } type ContentType { slug: String! + titles( + filters: ComponentTranslationsSimpleTitleFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): [ComponentTranslationsSimpleTitle] createdAt: DateTime updatedAt: DateTime } @@ -1711,7 +1743,6 @@ union LibraryItemMetadataDynamicZone = | ComponentMetadataVideo | ComponentMetadataGame | ComponentMetadataAudio - | ComponentMetadataMerch | ComponentMetadataOther | Error @@ -1725,8 +1756,10 @@ input LibraryItemFiltersInput { subitems: LibraryItemFiltersInput subitem_of: LibraryItemFiltersInput root_item: BooleanFilterInput - variants: LibraryVariantFiltersInput contents: RangedContentFiltersInput + digital: BooleanFilterInput + primary: BooleanFilterInput + submerchs: MerchItemFiltersInput createdAt: DateTimeFilterInput updatedAt: DateTimeFilterInput and: [LibraryItemFiltersInput] @@ -1743,7 +1776,6 @@ input LibraryItemInput { subitem_of: [ID] root_item: Boolean price: ComponentBasicsPriceInput - variants: ID metadata: [LibraryItemMetadataDynamicZoneInput!] size: ComponentBasicsSizeInput release_date: ComponentBasicsDatepickerInput @@ -1751,6 +1783,9 @@ input LibraryItemInput { gallery: [ID] contents: [ID] images: ComponentCollectionsComponentLibraryImagesInput + digital: Boolean + primary: Boolean + submerchs: [ID] } type LibraryItem { @@ -1770,7 +1805,6 @@ type LibraryItem { ): LibraryItemRelationResponseCollection root_item: Boolean! price: ComponentBasicsPrice - variants: LibraryVariantEntityResponse metadata: [LibraryItemMetadataDynamicZone] size: ComponentBasicsSize release_date: ComponentBasicsDatepicker @@ -1790,6 +1824,13 @@ type LibraryItem { sort: [String] = [] ): RangedContentRelationResponseCollection images: ComponentCollectionsComponentLibraryImages + digital: Boolean! + primary: Boolean! + submerchs( + filters: MerchItemFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): MerchItemRelationResponseCollection createdAt: DateTime updatedAt: DateTime } @@ -1812,47 +1853,12 @@ type LibraryItemRelationResponseCollection { data: [LibraryItemEntity!]! } -input LibraryVariantFiltersInput { - id: IDFilterInput - items: LibraryItemFiltersInput - createdAt: DateTimeFilterInput - updatedAt: DateTimeFilterInput - and: [LibraryVariantFiltersInput] - or: [LibraryVariantFiltersInput] - not: LibraryVariantFiltersInput -} - -input LibraryVariantInput { - items: [ID] -} - -type LibraryVariant { - items( - filters: LibraryItemFiltersInput - pagination: PaginationArg = {} - sort: [String] = [] - ): LibraryItemRelationResponseCollection - createdAt: DateTime - updatedAt: DateTime -} - -type LibraryVariantEntity { - id: ID - attributes: LibraryVariant -} - -type LibraryVariantEntityResponse { - data: LibraryVariantEntity -} - -type LibraryVariantEntityResponseCollection { - data: [LibraryVariantEntity!]! - meta: ResponseCollectionMeta! -} - input MerchItemFiltersInput { id: IDFilterInput slug: StringFilterInput + library_items: LibraryItemFiltersInput + title: StringFilterInput + subtitle: StringFilterInput createdAt: DateTimeFilterInput updatedAt: DateTimeFilterInput and: [MerchItemFiltersInput] @@ -1862,10 +1868,22 @@ input MerchItemFiltersInput { input MerchItemInput { slug: String + library_items: [ID] + title: String + subtitle: String + thumbnail: ID } type MerchItem { slug: String! + library_items( + filters: LibraryItemFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): LibraryItemRelationResponseCollection + title: String! + subtitle: String + thumbnail: UploadFileEntityResponse createdAt: DateTime updatedAt: DateTime } @@ -1884,6 +1902,10 @@ type MerchItemEntityResponseCollection { meta: ResponseCollectionMeta! } +type MerchItemRelationResponseCollection { + data: [MerchItemEntity!]! +} + input OtherSubtypeFiltersInput { id: IDFilterInput slug: StringFilterInput @@ -1896,10 +1918,16 @@ input OtherSubtypeFiltersInput { input OtherSubtypeInput { slug: String + titles: [ComponentTranslationsSimpleTitleInput] } type OtherSubtype { slug: String! + titles( + filters: ComponentTranslationsSimpleTitleFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): [ComponentTranslationsSimpleTitle] createdAt: DateTime updatedAt: DateTime } @@ -2137,10 +2165,16 @@ input TextualSubtypeFiltersInput { input TextualSubtypeInput { slug: String + titles: [ComponentTranslationsSimpleTitleInput] } type TextualSubtype { slug: String! + titles( + filters: ComponentTranslationsSimpleTitleFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): [ComponentTranslationsSimpleTitle] createdAt: DateTime updatedAt: DateTime } @@ -2298,6 +2332,172 @@ type WeaponStoryTypeEntityResponseCollection { meta: ResponseCollectionMeta! } +input WebsiteInterfaceFiltersInput { + id: IDFilterInput + language: LanguageFiltersInput + main_library: StringFilterInput + main_library_description: StringFilterInput + main_hub: StringFilterInput + main_hub_description: StringFilterInput + main_chronology: StringFilterInput + main_chronology_description: StringFilterInput + main_news: StringFilterInput + main_data: StringFilterInput + main_merch: StringFilterInput + main_gallery: StringFilterInput + main_archives: StringFilterInput + main_about_us: StringFilterInput + main_licensing: StringFilterInput + main_copyright: StringFilterInput + library_description: StringFilterInput + library_item_summary: StringFilterInput + library_item_gallery: StringFilterInput + library_item_details: StringFilterInput + library_item_subitems: StringFilterInput + library_item_variants: StringFilterInput + library_item_content: StringFilterInput + global_return_label: StringFilterInput + global_subitem_of: StringFilterInput + global_type: StringFilterInput + global_width: StringFilterInput + global_height: StringFilterInput + global_thickness: StringFilterInput + global_binding: StringFilterInput + global_language: StringFilterInput + global_languages: StringFilterInput + global_page: StringFilterInput + global_pages: StringFilterInput + global_page_order: StringFilterInput + global_release_date: StringFilterInput + global_price: StringFilterInput + library_item_physical_size: StringFilterInput + library_item_type_information: StringFilterInput + chronology_description: StringFilterInput + chronology_timelines: StringFilterInput + chronology_timelines_description: StringFilterInput + chronology_overview: StringFilterInput + chronology_overview_description: StringFilterInput + chronology_walkthrough: StringFilterInput + chronology_walkthrough_description: StringFilterInput + createdAt: DateTimeFilterInput + updatedAt: DateTimeFilterInput + and: [WebsiteInterfaceFiltersInput] + or: [WebsiteInterfaceFiltersInput] + not: WebsiteInterfaceFiltersInput +} + +input WebsiteInterfaceInput { + language: ID + 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 + main_about_us: String + main_licensing: String + main_copyright: String + library_description: String + library_item_summary: String + library_item_gallery: String + library_item_details: String + library_item_subitems: String + library_item_variants: String + library_item_content: String + global_return_label: String + global_subitem_of: String + global_type: String + global_width: String + global_height: String + global_thickness: String + global_binding: String + global_language: String + global_languages: String + global_page: String + global_pages: String + global_page_order: String + global_release_date: String + 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 +} + +type WebsiteInterface { + language: LanguageEntityResponse + 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 + main_about_us: String + main_licensing: String + main_copyright: String + library_description: String + library_item_summary: String + library_item_gallery: String + library_item_details: String + library_item_subitems: String + library_item_variants: String + library_item_content: String + global_return_label: String + global_subitem_of: String + global_type: String + global_width: String + global_height: String + global_thickness: String + global_binding: String + global_language: String + global_languages: String + global_page: String + global_pages: String + global_page_order: String + global_release_date: String + 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 + createdAt: DateTime + updatedAt: DateTime +} + +type WebsiteInterfaceEntity { + id: ID + attributes: WebsiteInterface +} + +type WebsiteInterfaceEntityResponse { + data: WebsiteInterfaceEntity +} + +type WebsiteInterfaceEntityResponseCollection { + data: [WebsiteInterfaceEntity!]! + meta: ResponseCollectionMeta! +} + union GenericMorph = ComponentBasicsCredits | ComponentBasicsDatepicker @@ -2340,6 +2540,7 @@ union GenericMorph = | ComponentTranslationsLibraryItems | ComponentTranslationsPosts | ComponentTranslationsScanSet + | ComponentTranslationsSimpleTitle | ComponentTranslationsTextSet | ComponentTranslationsTitle | ComponentTranslationsVideoSets @@ -2359,7 +2560,6 @@ union GenericMorph = | GlossaryItemType | Language | LibraryItem - | LibraryVariant | MerchItem | OtherSubtype | Post @@ -2370,6 +2570,7 @@ union GenericMorph = | WeaponStory | WeaponStoryGroup | WeaponStoryType + | WebsiteInterface input FileInfoInput { name: String @@ -2463,12 +2664,6 @@ type Query { pagination: PaginationArg = {} sort: [String] = [] ): LibraryItemEntityResponseCollection - libraryVariant(id: ID): LibraryVariantEntityResponse - libraryVariants( - filters: LibraryVariantFiltersInput - pagination: PaginationArg = {} - sort: [String] = [] - ): LibraryVariantEntityResponseCollection merchItem(id: ID): MerchItemEntityResponse merchItems( filters: MerchItemFiltersInput @@ -2530,6 +2725,12 @@ type Query { pagination: PaginationArg = {} sort: [String] = [] ): WeaponStoryTypeEntityResponseCollection + websiteInterface(id: ID): WebsiteInterfaceEntityResponse + websiteInterfaces( + filters: WebsiteInterfaceFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): WebsiteInterfaceEntityResponseCollection } type Mutation { @@ -2592,12 +2793,6 @@ type Mutation { createLibraryItem(data: LibraryItemInput!): LibraryItemEntityResponse updateLibraryItem(id: ID!, data: LibraryItemInput!): LibraryItemEntityResponse deleteLibraryItem(id: ID!): LibraryItemEntityResponse - createLibraryVariant(data: LibraryVariantInput!): LibraryVariantEntityResponse - updateLibraryVariant( - id: ID! - data: LibraryVariantInput! - ): LibraryVariantEntityResponse - deleteLibraryVariant(id: ID!): LibraryVariantEntityResponse createMerchItem(data: MerchItemInput!): MerchItemEntityResponse updateMerchItem(id: ID!, data: MerchItemInput!): MerchItemEntityResponse deleteMerchItem(id: ID!): MerchItemEntityResponse @@ -2647,6 +2842,14 @@ type Mutation { data: WeaponStoryTypeInput! ): WeaponStoryTypeEntityResponse deleteWeaponStoryType(id: ID!): WeaponStoryTypeEntityResponse + createWebsiteInterface( + data: WebsiteInterfaceInput! + ): WebsiteInterfaceEntityResponse + updateWebsiteInterface( + id: ID! + data: WebsiteInterfaceInput! + ): WebsiteInterfaceEntityResponse + deleteWebsiteInterface(id: ID!): WebsiteInterfaceEntityResponse upload( refId: ID ref: String diff --git a/src/pages/404.tsx b/src/pages/404.tsx index ac5c3b3..450b6df 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -2,18 +2,28 @@ import Link from "next/link"; import ContentPanel from "components/Panels/ContentPanel"; import { applyCustomAppProps } from "./_app"; import Head from "next/head"; +import { getWebsiteInterface } from "graphql/operations"; +import { GetStaticProps } from "next"; +import { GetWebsiteInterfaceQuery } from "graphql/operations-types"; +import MainPanel from "components/Panels/MainPanel"; applyCustomAppProps(FourOhFour, { useSubPanel: false, useContentPanel: true, }); -export default function FourOhFour(): JSX.Element { +type Props = { + langui: GetWebsiteInterfaceQuery; +}; + +export default function FourOhFour(props: Props): JSX.Element { + const langui = props.langui.websiteInterfaces.data[0].attributes; return ( <> Accord’s Library - 404 +

404 - Page Not Found

@@ -23,3 +33,17 @@ export default function FourOhFour(): JSX.Element { ); } + +export const getStaticProps: GetStaticProps = async (context) => { + if (context.locale) { + const props: Props = { + langui: await getWebsiteInterface({ + language_code: context.locale, + }), + }; + return { + props: props, + }; + } + return { props: {} }; +}; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index e1d1cf7..9fbe713 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -31,7 +31,6 @@ export default function AccordsLibraryApp(appProps: AppProps) { : "grid grid-cols-[20rem]" } > -
); diff --git a/src/pages/chronology/index.tsx b/src/pages/chronology/index.tsx index 7b12763..c5223ac 100644 --- a/src/pages/chronology/index.tsx +++ b/src/pages/chronology/index.tsx @@ -2,43 +2,67 @@ import SubPanel from "components/Panels/SubPanel"; import NavOption from "components/PanelComponents/NavOption"; import { applyCustomAppProps } from "pages/_app"; import PanelHeader from "components/PanelComponents/PanelHeader"; +import MainPanel from "components/Panels/MainPanel"; +import { GetWebsiteInterfaceQuery } from "graphql/operations-types"; +import { GetStaticProps } from "next"; +import { getWebsiteInterface } from "graphql/operations"; applyCustomAppProps(Chronology, { useSubPanel: true, useContentPanel: false, }); -export default function Chronology(): JSX.Element { +type Props = { + langui: GetWebsiteInterfaceQuery; +}; + +export default function Chronology(props: Props): JSX.Element { + const langui = props.langui.websiteInterfaces.data[0].attributes; return ( <> + ); } + +export const getStaticProps: GetStaticProps = async (context) => { + if (context.locale) { + const props: Props = { + langui: await getWebsiteInterface({ + language_code: context.locale, + }), + }; + return { + props: props, + }; + } + return { props: {} }; +}; diff --git a/src/pages/chronology/overview.tsx b/src/pages/chronology/overview.tsx index 0e1e331..274d1b4 100644 --- a/src/pages/chronology/overview.tsx +++ b/src/pages/chronology/overview.tsx @@ -6,15 +6,22 @@ import { applyCustomAppProps } from "pages/_app"; import { GetChronologyItemsQuery, GetErasQuery, + GetWebsiteInterfaceQuery, } from "graphql/operations-types"; -import { getEras, getChronologyItems } from "graphql/operations"; +import { + getEras, + getChronologyItems, + getWebsiteInterface, +} from "graphql/operations"; import NavOption from "components/PanelComponents/NavOption"; import ReturnButton from "components/PanelComponents/ReturnButton"; import HorizontalLine from "components/HorizontalLine"; +import MainPanel from "components/Panels/MainPanel"; interface Props { chronologyItems: GetChronologyItemsQuery; chronologyEras: GetErasQuery; + langui: GetWebsiteInterfaceQuery; } applyCustomAppProps(ChronologyOverview, { @@ -24,7 +31,7 @@ applyCustomAppProps(ChronologyOverview, { export default function ChronologyOverview(props: Props): JSX.Element { // Group by year the Chronology items - + const langui = props.langui.websiteInterfaces.data[0].attributes; let chronologyItemYearGroups: GetChronologyItemsQuery["chronologyItems"]["data"][number][][] = []; @@ -40,8 +47,9 @@ export default function ChronologyOverview(props: Props): JSX.Element { return ( <> + - + {props.chronologyEras.chronologyEras.data.map((era) => ( @@ -75,16 +83,19 @@ export default function ChronologyOverview(props: Props): JSX.Element { } export const getStaticProps: GetStaticProps = async (context) => { - if (context.locale) - return { - props: { - chronologyItems: await getChronologyItems({ - language_code: context.locale, - }), - chronologyEras: await getEras({ language_code: context.locale }), - }, + if (context.locale) { + const props: Props = { + chronologyItems: await getChronologyItems({ + language_code: context.locale, + }), + chronologyEras: await getEras({ language_code: context.locale }), + langui: await getWebsiteInterface({ + language_code: context.locale, + }), + }; + return { + props: props, }; - else { - return { props: {} }; } + return { props: {} }; }; diff --git a/src/pages/content/[slug]/index.tsx b/src/pages/content/[slug]/index.tsx index 263897d..9823082 100644 --- a/src/pages/content/[slug]/index.tsx +++ b/src/pages/content/[slug]/index.tsx @@ -1,16 +1,25 @@ import { GetStaticPaths, GetStaticProps } from "next"; import { applyCustomAppProps } from "pages/_app"; -import { getContent, getContentsSlugs } from "graphql/operations"; -import { GetContentQuery } from "graphql/operations-types"; +import { + getContent, + getContentsSlugs, + getWebsiteInterface, +} from "graphql/operations"; +import { + GetContentQuery, + GetWebsiteInterfaceQuery, +} from "graphql/operations-types"; import ContentPanel from "components/Panels/ContentPanel"; import Image from "next/image"; import { getAssetURL, prettySlug } from "queries/helpers"; import Button from "components/Button"; import HorizontalLine from "components/HorizontalLine"; import ThumbnailHeader from "components/Content/ThumbnailHeader"; +import MainPanel from "components/Panels/MainPanel"; type Props = { content: GetContentQuery; + langui: GetWebsiteInterfaceQuery; }; applyCustomAppProps(Library, { @@ -20,9 +29,11 @@ applyCustomAppProps(Library, { export default function Library(props: Props): JSX.Element { const content = props.content.contents.data[0].attributes; + const langui = props.langui.websiteInterfaces.data[0].attributes; return ( <> +
@@ -63,30 +74,38 @@ export const getStaticProps: GetStaticProps = async (context) => { if (context.params.slug && context.locale) { if (context.params.slug instanceof Array) context.params.slug = context.params.slug.join(""); + + const props: Props = { + content: await getContent({ + slug: context.params.slug, + language_code: context.locale, + }), + langui: await getWebsiteInterface({ + language_code: context.locale, + }), + }; return { - props: { - content: await getContent({ - slug: context.params.slug, - language_code: context.locale, - }), - }, + props: props, }; } } return { props: {} }; }; -export const getStaticPaths: GetStaticPaths = async () => { +export const getStaticPaths: GetStaticPaths = async (context) => { type Path = { params: { slug: string; }; + locale: string; }; const data = await getContentsSlugs({}); const paths: Path[] = []; data.contents.data.map((item) => { - paths.push({ params: { slug: item.attributes.slug } }); + context.locales?.map((local) => { + paths.push({ params: { slug: item.attributes.slug }, locale: local }); + }); }); return { paths, diff --git a/src/pages/content/[slug]/read.tsx b/src/pages/content/[slug]/read.tsx index bbd22db..e7e94ff 100644 --- a/src/pages/content/[slug]/read.tsx +++ b/src/pages/content/[slug]/read.tsx @@ -1,7 +1,14 @@ import { GetStaticPaths, GetStaticProps } from "next"; import { applyCustomAppProps } from "pages/_app"; -import { getContentsSlugs, getContentText } from "graphql/operations"; -import { GetContentTextQuery } from "graphql/operations-types"; +import { + getContentsSlugs, + getContentText, + getWebsiteInterface, +} from "graphql/operations"; +import { + GetContentTextQuery, + GetWebsiteInterfaceQuery, +} from "graphql/operations-types"; import ContentPanel from "components/Panels/ContentPanel"; import Image from "next/image"; import { getAssetURL, prettySlug } from "queries/helpers"; @@ -12,9 +19,11 @@ import SubPanel from "components/Panels/SubPanel"; import ReturnButton from "components/PanelComponents/ReturnButton"; import SceneBreak from "components/Markdown/SceneBreak"; import ThumbnailHeader from "components/Content/ThumbnailHeader"; +import MainPanel from "components/Panels/MainPanel"; type Props = { content: GetContentTextQuery; + langui: GetWebsiteInterfaceQuery; }; applyCustomAppProps(Library, { @@ -24,11 +33,13 @@ applyCustomAppProps(Library, { export default function Library(props: Props): JSX.Element { const content = props.content.contents.data[0].attributes; + const langui = props.langui.websiteInterfaces.data[0].attributes; return ( <> + - +
@@ -54,33 +65,41 @@ export default function Library(props: Props): JSX.Element { export const getStaticProps: GetStaticProps = async (context) => { if (context.params) { - if (context.params.slug instanceof Array) - context.params.slug = context.params.slug.join(""); if (context.params.slug && context.locale) { + if (context.params.slug instanceof Array) + context.params.slug = context.params.slug.join(""); + + const props: Props = { + content: await getContentText({ + slug: context.params.slug, + language_code: context.locale, + }), + langui: await getWebsiteInterface({ + language_code: context.locale, + }), + }; return { - props: { - content: await getContentText({ - slug: context.params.slug, - language_code: context.locale, - }), - }, + props: props, }; } } return { props: {} }; }; -export const getStaticPaths: GetStaticPaths = async () => { +export const getStaticPaths: GetStaticPaths = async (context) => { type Path = { params: { slug: string; }; + locale: string; }; const data = await getContentsSlugs({}); const paths: Path[] = []; data.contents.data.map((item) => { - paths.push({ params: { slug: item.attributes.slug } }); + context.locales?.map((local) => { + paths.push({ params: { slug: item.attributes.slug }, locale: local }); + }); }); return { paths, diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 6b93ef0..607be2c 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -1,13 +1,23 @@ +import MainPanel from "components/Panels/MainPanel"; +import { getWebsiteInterface } from "graphql/operations"; +import { GetWebsiteInterfaceQuery } from "graphql/operations-types"; +import { GetStaticProps } from "next"; import { applyCustomAppProps } from "pages/_app"; -applyCustomAppProps(Chronology, { +applyCustomAppProps(Gallery, { useSubPanel: false, useContentPanel: true, }); -export default function Chronology(): JSX.Element { +type Props = { + langui: GetWebsiteInterfaceQuery; +}; + +export default function Gallery(props: Props): JSX.Element { + const langui = props.langui.websiteInterfaces.data[0].attributes; return ( <> +