diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 54f4e51..8a8fcd9 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -26,7 +26,7 @@ export default function FourOhFour(props: FourOhFourProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: FourOhFourProps }> { +): Promise<{ notFound: boolean } | { props: FourOhFourProps }> { const props: FourOhFourProps = { ...(await getAppStaticProps(context)), }; diff --git a/src/pages/500.tsx b/src/pages/500.tsx new file mode 100644 index 0000000..c0e77fc --- /dev/null +++ b/src/pages/500.tsx @@ -0,0 +1,36 @@ +import AppLayout from "components/AppLayout"; +import ReturnButton, { + ReturnButtonType, +} from "components/PanelComponents/ReturnButton"; +import ContentPanel from "components/Panels/ContentPanel"; +import { GetStaticPropsContext } from "next"; +import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; + +interface FiveHundredProps extends AppStaticProps {} + +export default function FiveHundred(props: FiveHundredProps): JSX.Element { + const { langui } = props; + const contentPanel = ( + +

500 - Internal Server Error

+ +
+ ); + return ; +} + +export async function getStaticProps( + context: GetStaticPropsContext +): Promise<{ notFound: boolean } | { props: FiveHundredProps }> { + const props: FiveHundredProps = { + ...(await getAppStaticProps(context)), + }; + return { + props: props, + }; +} diff --git a/src/pages/about-us/accords-handbook.tsx b/src/pages/about-us/accords-handbook.tsx index 4c7ab4e..d8ccf03 100644 --- a/src/pages/about-us/accords-handbook.tsx +++ b/src/pages/about-us/accords-handbook.tsx @@ -80,7 +80,7 @@ export default function AccordsHandbook( export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: AccordsHandbookProps }> { +): Promise<{ notFound: boolean } | { props: AccordsHandbookProps }> { const slug = "accords-handbook"; const props: AccordsHandbookProps = { ...(await getAppStaticProps(context)), diff --git a/src/pages/about-us/contact.tsx b/src/pages/about-us/contact.tsx index a7a6d52..74151b3 100644 --- a/src/pages/about-us/contact.tsx +++ b/src/pages/about-us/contact.tsx @@ -224,7 +224,7 @@ export default function AboutUs(props: ContactProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: ContactProps }> { +): Promise<{ notFound: boolean } | { props: ContactProps }> { const slug = "contact"; const props: ContactProps = { ...(await getAppStaticProps(context)), diff --git a/src/pages/about-us/index.tsx b/src/pages/about-us/index.tsx index ca2d3a9..f846789 100644 --- a/src/pages/about-us/index.tsx +++ b/src/pages/about-us/index.tsx @@ -38,7 +38,7 @@ export default function AboutUs(props: AboutUsProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: AboutUsProps }> { +): Promise<{ notFound: boolean } | { props: AboutUsProps }> { const props: AboutUsProps = { ...(await getAppStaticProps(context)), }; diff --git a/src/pages/about-us/legality.tsx b/src/pages/about-us/legality.tsx index 8f65be0..60c6fac 100644 --- a/src/pages/about-us/legality.tsx +++ b/src/pages/about-us/legality.tsx @@ -78,7 +78,7 @@ export default function SiteInformation(props: SiteInfoProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: SiteInfoProps }> { +): Promise<{ notFound: boolean } | { props: SiteInfoProps }> { const slug = "legality"; const props: SiteInfoProps = { ...(await getAppStaticProps(context)), diff --git a/src/pages/about-us/sharing-policy.tsx b/src/pages/about-us/sharing-policy.tsx index e75729b..50a9ac7 100644 --- a/src/pages/about-us/sharing-policy.tsx +++ b/src/pages/about-us/sharing-policy.tsx @@ -78,7 +78,7 @@ export default function SharingPolicy(props: SharingPolicyProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: SharingPolicyProps }> { +): Promise<{ notFound: boolean } | { props: SharingPolicyProps }> { const slug = "sharing-policy"; const props: SharingPolicyProps = { ...(await getAppStaticProps(context)), diff --git a/src/pages/archives/index.tsx b/src/pages/archives/index.tsx index b73a205..61c86f0 100644 --- a/src/pages/archives/index.tsx +++ b/src/pages/archives/index.tsx @@ -24,7 +24,7 @@ export default function Archives(props: ArchivesProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: ArchivesProps }> { +): Promise<{ notFound: boolean } | { props: ArchivesProps }> { const props: ArchivesProps = { ...(await getAppStaticProps(context)), }; diff --git a/src/pages/chronicles/index.tsx b/src/pages/chronicles/index.tsx index 7d3f8af..4f1d4f3 100644 --- a/src/pages/chronicles/index.tsx +++ b/src/pages/chronicles/index.tsx @@ -22,9 +22,9 @@ export default function Chronicles(props: ChroniclesProps): JSX.Element { ); } -export async function getStaticProps(context: GetStaticPropsContext): Promise<{ - props: ChroniclesProps; -}> { +export async function getStaticProps( + context: GetStaticPropsContext +): Promise<{ notFound: boolean } | { props: ChroniclesProps }> { const props: ChroniclesProps = { ...(await getAppStaticProps(context)), }; diff --git a/src/pages/contents/[slug]/index.tsx b/src/pages/contents/[slug]/index.tsx index 11cce87..2307c27 100644 --- a/src/pages/contents/[slug]/index.tsx +++ b/src/pages/contents/[slug]/index.tsx @@ -134,17 +134,19 @@ export default function ContentIndex(props: ContentIndexProps): JSX.Element { ); } -export async function getStaticProps(context: GetStaticPropsContext): Promise<{ - props: ContentIndexProps; -}> { +export async function getStaticProps( + context: GetStaticPropsContext +): Promise<{ notFound: boolean } | { props: ContentIndexProps }> { + const content = ( + await getContent({ + slug: context.params?.slug?.toString() ?? "", + language_code: context.locale ?? "en", + }) + ).contents.data[0].attributes; + if (!content) return { notFound: true }; const props: ContentIndexProps = { ...(await getAppStaticProps(context)), - content: ( - await getContent({ - slug: context.params?.slug?.toString() ?? "", - language_code: context.locale ?? "en", - }) - ).contents.data[0].attributes, + content: content, }; return { props: props, diff --git a/src/pages/contents/[slug]/read.tsx b/src/pages/contents/[slug]/read.tsx index 29b2ab0..7ba8ed8 100644 --- a/src/pages/contents/[slug]/read.tsx +++ b/src/pages/contents/[slug]/read.tsx @@ -246,7 +246,7 @@ export default function ContentRead(props: ContentReadProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: ContentReadProps }> { +): Promise<{ notFound: boolean } | { props: ContentReadProps }> { const slug = context.params?.slug?.toString() ?? ""; const content = ( await getContentText({ @@ -254,6 +254,7 @@ export async function getStaticProps( language_code: context.locale ?? "en", }) ).contents.data[0]; + if (!content) return { notFound: true }; const props: ContentReadProps = { ...(await getAppStaticProps(context)), content: content.attributes, diff --git a/src/pages/contents/index.tsx b/src/pages/contents/index.tsx index 7fae246..143418f 100644 --- a/src/pages/contents/index.tsx +++ b/src/pages/contents/index.tsx @@ -101,7 +101,7 @@ export default function Contents(props: ContentsProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: ContentsProps }> { +): Promise<{ notFound: boolean } | { props: ContentsProps }> { const contents = ( await getContents({ language_code: context.locale ?? "en", diff --git a/src/pages/editor.tsx b/src/pages/editor.tsx index f919125..ec5bb22 100644 --- a/src/pages/editor.tsx +++ b/src/pages/editor.tsx @@ -91,7 +91,7 @@ export default function Editor(props: EditorProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: EditorProps }> { +): Promise<{ notFound: boolean } | { props: EditorProps }> { const props: EditorProps = { ...(await getAppStaticProps(context)), }; diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 61ce441..b12514f 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -24,7 +24,7 @@ export default function Gallery(props: GalleryProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: GalleryProps }> { +): Promise<{ notFound: boolean } | { props: GalleryProps }> { const props: GalleryProps = { ...(await getAppStaticProps(context)), }; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 9a75997..48dbd2d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -54,7 +54,7 @@ export default function Home(props: HomeProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: HomeProps }> { +): Promise<{ notFound: boolean } | { props: HomeProps }> { const slug = "home"; const props: HomeProps = { ...(await getAppStaticProps(context)), diff --git a/src/pages/library/[slug]/index.tsx b/src/pages/library/[slug]/index.tsx index 130758a..521ef57 100644 --- a/src/pages/library/[slug]/index.tsx +++ b/src/pages/library/[slug]/index.tsx @@ -416,13 +416,14 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: LibrarySlugProps }> { +): Promise<{ notFound: boolean } | { props: LibrarySlugProps }> { const item = ( await getLibraryItem({ slug: context.params?.slug?.toString() ?? "", language_code: context.locale ?? "en", }) ).libraryItems.data[0]; + if (!item) return { notFound: true }; const props: LibrarySlugProps = { ...(await getAppStaticProps(context)), item: item.attributes, diff --git a/src/pages/library/[slug]/scans.tsx b/src/pages/library/[slug]/scans.tsx index 6ab8e82..062937e 100644 --- a/src/pages/library/[slug]/scans.tsx +++ b/src/pages/library/[slug]/scans.tsx @@ -146,13 +146,14 @@ export default function LibrarySlug(props: Props): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: Props }> { +): Promise<{ notFound: boolean } | { props: Props }> { const item = ( await getLibraryItemScans({ slug: context.params?.slug?.toString() ?? "", language_code: context.locale ?? "en", }) ).libraryItems.data[0]; + if (!item) return { notFound: true }; const props: Props = { ...(await getAppStaticProps(context)), item: item.attributes, diff --git a/src/pages/library/index.tsx b/src/pages/library/index.tsx index 257ade7..05051f0 100644 --- a/src/pages/library/index.tsx +++ b/src/pages/library/index.tsx @@ -167,7 +167,7 @@ export default function Library(props: LibraryProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: LibraryProps }> { +): Promise<{ notFound: boolean } | { props: LibraryProps }> { const props: LibraryProps = { ...(await getAppStaticProps(context)), items: ( diff --git a/src/pages/merch/index.tsx b/src/pages/merch/index.tsx index b7e606b..1a70a06 100644 --- a/src/pages/merch/index.tsx +++ b/src/pages/merch/index.tsx @@ -22,7 +22,7 @@ export default function Merch(props: MerchProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: MerchProps }> { +): Promise<{ notFound: boolean } | { props: MerchProps }> { const props: MerchProps = { ...(await getAppStaticProps(context)), }; diff --git a/src/pages/news/[slug].tsx b/src/pages/news/[slug].tsx index 9e80cd4..e320b50 100644 --- a/src/pages/news/[slug].tsx +++ b/src/pages/news/[slug].tsx @@ -146,7 +146,7 @@ export default function LibrarySlug(props: PostProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: PostProps }> { +): Promise<{ notFound: boolean } | { props: PostProps }> { const slug = context.params?.slug?.toString() ?? ""; const post = ( await getPost({ @@ -154,6 +154,7 @@ export async function getStaticProps( language_code: context.locale ?? "en", }) ).posts.data[0]; + if (!post) return { notFound: true }; const props: PostProps = { ...(await getAppStaticProps(context)), post: post.attributes, diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx index 6f6c131..0413d4e 100644 --- a/src/pages/news/index.tsx +++ b/src/pages/news/index.tsx @@ -60,7 +60,7 @@ export default function News(props: NewsProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: NewsProps }> { +): Promise<{ notFound: boolean } | { props: NewsProps }> { const props: NewsProps = { ...(await getAppStaticProps(context)), posts: await ( diff --git a/src/pages/wiki/chronology.tsx b/src/pages/wiki/chronology.tsx index 59ca190..5235cf8 100644 --- a/src/pages/wiki/chronology.tsx +++ b/src/pages/wiki/chronology.tsx @@ -143,7 +143,7 @@ export default function Chronology(props: ChronologyProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: ChronologyProps }> { +): Promise<{ notFound: boolean } | { props: ChronologyProps }> { const props: ChronologyProps = { ...(await getAppStaticProps(context)), chronologyItems: ( diff --git a/src/pages/wiki/index.tsx b/src/pages/wiki/index.tsx index 7803919..ab12747 100644 --- a/src/pages/wiki/index.tsx +++ b/src/pages/wiki/index.tsx @@ -25,7 +25,7 @@ export default function Wiki(props: WikiProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ props: WikiProps }> { +): Promise<{ notFound: boolean } | { props: WikiProps }> { const props: WikiProps = { ...(await getAppStaticProps(context)), };