From 5992a0a51b9a4a9aa98d418b68f029aad05eb532 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Wed, 4 May 2022 13:58:26 -0500 Subject: [PATCH] Add catch all page --- src/pages/[...page].astro | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/pages/[...page].astro diff --git a/src/pages/[...page].astro b/src/pages/[...page].astro new file mode 100644 index 0000000..f27b990 --- /dev/null +++ b/src/pages/[...page].astro @@ -0,0 +1,28 @@ +--- +// import { getPathPartsFromAstroRequest } from '~/helpers/url.js' +import { catchRedirectResponse } from '~/helpers/astro/request.js' + +import Layout from '../layouts/default.astro' + +// Component Script: +// You can write any JavaScript/TypeScript that you'd like here. +// It will run during the build, but never in the browser. +// All variables are available to use in the HTML template below. + +// Full Astro Component Syntax: +// https://docs.astro.build/core-concepts/astro-components/ + +const redirectResponse = await catchRedirectResponse( Astro ) + +if ( redirectResponse !== null ) { + return redirectResponse +} + +// Not found +return new Response(null, { + status: 404, + statusText: 'Not found' +}) + +--- +404