From 3ab6f77a6915cbf8dbcaaee79de5ee2c34efebc5 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 17 Nov 2024 09:08:15 -0800 Subject: [PATCH] chore: middleware --- astro.config.mjs | 5 ++ src/components/Footer.astro | 3 +- src/components/Header.astro | 3 +- src/components/Metadata.astro | 2 +- src/components/media/Grid.astro | 3 +- src/components/media/music/Recent.astro | 3 +- src/components/media/watching/Hero.astro | 3 +- src/layouts/Layout.astro | 13 ++- src/middleware.js | 19 ++++ src/pages/[permalink].astro | 3 +- src/pages/blogroll.astro | 5 -- src/pages/books/[isbn].astro | 108 +++++++++++++++++++++++ src/pages/books/index.astro | 5 +- src/pages/index.astro | 3 +- src/pages/links.astro | 3 +- src/pages/posts/[...page].astro | 3 +- src/pages/posts/[year]/[title].astro | 6 +- src/utils/data/bookByUrl.js | 26 ++++++ 18 files changed, 180 insertions(+), 36 deletions(-) create mode 100644 src/middleware.js create mode 100644 src/pages/books/[isbn].astro create mode 100644 src/utils/data/bookByUrl.js diff --git a/astro.config.mjs b/astro.config.mjs index 0e37b3b..7f3c7be 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -6,6 +6,11 @@ export default defineConfig({ output: "server", adapter: cloudflare(), integrations: [react()], + server: { + middleware: { + onRequest: "./src/middleware.js", + }, + }, vite: { build: { sourcemap: false, diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 78720e1..0f9bfd4 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,7 +1,8 @@ --- import NavLink from '@components/nav/NavLink.astro'; -const { nav, updated } = Astro.props; +const { updated } = Astro.props; +const { nav } = Astro.locals; ---