From e80b2b2ab69bb1735f4b811cc38fa7692baf0225 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 01:18:34 +0100 Subject: [PATCH 1/2] Quick fix for the last commit --- src/pages/library/[slug].tsx | 115 +++++------------------------------ src/queries/helpers.ts | 2 +- 2 files changed, 16 insertions(+), 101 deletions(-) diff --git a/src/pages/library/[slug].tsx b/src/pages/library/[slug].tsx index 235eb31..8261f4d 100644 --- a/src/pages/library/[slug].tsx +++ b/src/pages/library/[slug].tsx @@ -51,7 +51,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { const isVariantSet = item.metadata.length > 0 && - item.metadata[0].__typename === "ComponentMetadataOther" && + item.metadata[0].__typename === "ComponentMetadataGroup" && item.metadata[0].subtype.data.attributes.slug === "variant-set"; sortContent(item.contents); @@ -184,9 +184,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
-

- {langui.details} -

+

{langui.details}

{item.metadata.length > 0 ? (
@@ -256,9 +254,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { {item.metadata.length > 0 ? ( <> -

- {langui.type_information} -

+

{langui.type_information}

{item.metadata[0].__typename === "ComponentMetadataBooks" ? ( <> @@ -312,21 +308,8 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { "ComponentMetadataGame" ? ( <> ) : item.metadata[0].__typename === - "ComponentMetadataOther" ? ( - <> -
-

{langui.type}:

- - {item.metadata[0].subtype.data.attributes.titles - .length > 0 - ? item.metadata[0].subtype.data.attributes.titles[0] - .title - : prettySlug( - item.metadata[0].subtype.data.attributes.slug - )} - -
- + "ComponentMetadataGroup" ? ( + <> ) : ( "" )} @@ -344,9 +327,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { className="grid place-items-center gap-8 w-full" >

- {isVariantSet - ? langui.variants - : langui.subitems} + {isVariantSet ? langui.variants : langui.subitems}

{item.subitems.data.map((subitem) => ( @@ -549,7 +530,7 @@ function useTesting(props: LibrarySlugProps) { ); } else { if ( - libraryItem.metadata[0].__typename === "ComponentMetadataOther" && + libraryItem.metadata[0].__typename === "ComponentMetadataGroup" && (libraryItem.metadata[0].subtype.data.attributes.slug === "relation-set" || libraryItem.metadata[0].subtype.data.attributes.slug === @@ -599,80 +580,14 @@ function useTesting(props: LibrarySlugProps) { } else { // This is a normal item - if (libraryItem.metadata[0].__typename === "ComponentMetadataOther") { - if ( - libraryItem.metadata[0].subtype.data.attributes.slug === - "audio-case" - ) { - let hasAudioSubItem = false; - libraryItem.subitems.data.map((subitem) => { - if ( - subitem.attributes.metadata.length > 0 && - subitem.attributes.metadata[0].__typename === - "ComponentMetadataAudio" - ) - hasAudioSubItem = true; - }); - if (!hasAudioSubItem) { - prettyTestError( - router, - "Audio-case item doesn't have an audio-typed subitem", - ["libraryItem"], - libraryItemURL - ); - } - } else if ( - libraryItem.metadata[0].subtype.data.attributes.slug === "game-case" - ) { - let hasGameSubItem = false; - libraryItem.subitems.data.map((subitem) => { - if ( - subitem.attributes.metadata.length > 0 && - subitem.attributes.metadata[0].__typename === - "ComponentMetadataGame" - ) - hasGameSubItem = true; - }); - if (!hasGameSubItem) { - prettyTestError( - router, - "Game-case item doesn't have an Game-typed subitem", - ["libraryItem"], - libraryItemURL - ); - } - } else if ( - libraryItem.metadata[0].subtype.data.attributes.slug === - "video-case" - ) { - let hasVideoSubItem = false; - libraryItem.subitems.data.map((subitem) => { - if ( - subitem.attributes.metadata.length > 0 && - subitem.attributes.metadata[0].__typename === - "ComponentMetadataVideo" - ) - hasVideoSubItem = true; - }); - if (!hasVideoSubItem) { - prettyTestError( - router, - "Video-case item doesn't have an Video-typed subitem", - ["libraryItem"], - libraryItemURL - ); - } - } else if ( - libraryItem.metadata[0].subtype.data.attributes.slug === "item-set" - ) { - if (libraryItem.subitems.data.length === 0) { - prettyTestError( - router, - "Item-set item should have subitems", - ["libraryItem"], - libraryItemURL - ); - } + if (libraryItem.metadata[0].__typename === "ComponentMetadataGroup") { + if (libraryItem.subitems.data.length === 0) { + prettyTestError( + router, + "Group-type item should have subitems", + ["libraryItem"], + libraryItemURL + ); } } diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts index 6d9c5b5..c9d11c3 100644 --- a/src/queries/helpers.ts +++ b/src/queries/helpers.ts @@ -108,7 +108,7 @@ export function prettyItemSubType(metadata: { metadata.subitems_type.data.attributes.titles.length > 0 ? metadata.subitems_type.data.attributes.titles[0].title : prettySlug(metadata.subitems_type.data.attributes.slug); - return `${secondPart} ${firstPart})`; + return `${secondPart} ${firstPart}`; } default: return ""; -- 2.40.1 From ae5e37c002793446d41d536820128a0d08b81854 Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 01:21:43 +0100 Subject: [PATCH 2/2] Create node.js.yml --- .github/workflows/node.js.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..57e68ee --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,30 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present -- 2.40.1