From 0bc2a5ab0f253ebf1bf1af6997a031124efb4e87 Mon Sep 17 00:00:00 2001 From: DrMint Date: Thu, 24 Feb 2022 13:25:43 +0100 Subject: [PATCH] Tested deployment --- run_accords_build.sh | 1 + run_accords.sh => run_accords_dev.sh | 0 run_accords_prod.sh | 1 + src/pages/contents/[slug]/index.tsx | 6 +++++- src/queries/helpers.ts | 23 ++++++++++++++--------- 5 files changed, 21 insertions(+), 10 deletions(-) create mode 100755 run_accords_build.sh rename run_accords.sh => run_accords_dev.sh (100%) create mode 100755 run_accords_prod.sh diff --git a/run_accords_build.sh b/run_accords_build.sh new file mode 100755 index 0000000..2e23821 --- /dev/null +++ b/run_accords_build.sh @@ -0,0 +1 @@ +npx next build diff --git a/run_accords.sh b/run_accords_dev.sh similarity index 100% rename from run_accords.sh rename to run_accords_dev.sh diff --git a/run_accords_prod.sh b/run_accords_prod.sh new file mode 100755 index 0000000..2ff712c --- /dev/null +++ b/run_accords_prod.sh @@ -0,0 +1 @@ +npx next start -p 12500 diff --git a/src/pages/contents/[slug]/index.tsx b/src/pages/contents/[slug]/index.tsx index a1b04f2..6ececaa 100644 --- a/src/pages/contents/[slug]/index.tsx +++ b/src/pages/contents/[slug]/index.tsx @@ -70,7 +70,11 @@ export default function ContentIndex(props: ContentIndexProps): JSX.Element { navTitle="Contents" title={ content.titles.length > 0 - ? prettyinlineTitle(content.titles[0].pre_title, content.titles[0].title, content.titles[0].subtitle) + ? prettyinlineTitle( + content.titles[0].pre_title, + content.titles[0].title, + content.titles[0].subtitle + ) : prettySlug(content.slug) } thumbnail={content.thumbnail.data.attributes} diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts index c806703..e9f07ff 100644 --- a/src/queries/helpers.ts +++ b/src/queries/helpers.ts @@ -30,12 +30,15 @@ export function prettyPrice( ); } -export function prettySlug(slug: string, parentSlug?: string): string { - if (parentSlug && slug.startsWith(parentSlug)) - slug = slug.substring(parentSlug.length + 1); - slug = slug.replace(new RegExp("-", "g"), " "); - slug = slug.replace(new RegExp("_", "g"), " "); - return capitalizeString(slug); +export function prettySlug(slug?: string, parentSlug?: string): string { + if (slug) { + if (parentSlug && slug.startsWith(parentSlug)) + slug = slug.substring(parentSlug.length + 1); + slug = slug.replace(new RegExp("-", "g"), " "); + slug = slug.replace(new RegExp("_", "g"), " "); + return capitalizeString(slug); + } + return ""; } export function prettyinlineTitle( @@ -73,9 +76,11 @@ export function prettyItemType( } } -export function prettyItemSubType( - metadata: GetLibraryItemsPreviewQuery["libraryItems"]["data"][number]["attributes"]["metadata"][number] -): string { +export function prettyItemSubType(metadata: { + __typename: GetLibraryItemsPreviewQuery["libraryItems"]["data"][number]["attributes"]["metadata"][number]["__typename"]; + subtype?: any; + platform?: any; +}): string { switch (metadata.__typename) { case "ComponentMetadataAudio": case "ComponentMetadataBooks":