From e4d2b4ec053be1112f8dd561b659bd2465def3ff Mon Sep 17 00:00:00 2001 From: codey Date: Sat, 22 Nov 2025 12:12:56 -0500 Subject: [PATCH] - Replaced global navbar, now mobile friendly - Corrected sizing of LyricSearchInputField - Removed sitemap from auto-generated robots.txt --- src/components/LyricSearch.jsx | 3 +- src/layouts/Nav.astro | 295 ++++++++++++++++++++++++++------- src/middleware.js | 20 +++ src/pages/robots.txt.js | 9 +- 4 files changed, 262 insertions(+), 65 deletions(-) create mode 100644 src/middleware.js diff --git a/src/components/LyricSearch.jsx b/src/components/LyricSearch.jsx index a351334..3c8e239 100644 --- a/src/components/LyricSearch.jsx +++ b/src/components/LyricSearch.jsx @@ -247,7 +247,8 @@ export function LyricSearchInputField({ id, placeholder, setShowLyrics }) { onShow={handlePanelShow} placeholder={placeholder} autoFocus - size={40} + style={{ width: '100%', maxWidth: '900px' }} + inputStyle={{ width: '100%' }} aria-controls="lyric-search-input" /> - - + + + +
+ + + + +
+ + + +
+ +
+ + diff --git a/src/middleware.js b/src/middleware.js new file mode 100644 index 0000000..9d1990d --- /dev/null +++ b/src/middleware.js @@ -0,0 +1,20 @@ +import { defineMiddleware } from 'astro:middleware'; + +export const onRequest = defineMiddleware(async (context, next) => { + try { + // Let Astro handle the request first + const response = await next(); + + // If it's a 404, redirect to home + if (response.status === 404) { + console.log(`404 redirect: ${context.url.pathname} -> /`); + return context.redirect('/', 302); + } + + return response; + } catch (error) { + // Handle any middleware errors by redirecting to home + console.error('Middleware error:', error); + return context.redirect('/', 302); + } +}); \ No newline at end of file diff --git a/src/pages/robots.txt.js b/src/pages/robots.txt.js index 43215c6..454001a 100644 --- a/src/pages/robots.txt.js +++ b/src/pages/robots.txt.js @@ -1,11 +1,8 @@ -const getRobotsTxt = (sitemapURL) => ` +const getRobotsTxt = () => ` User-agent: * Allow: / - -Sitemap: ${sitemapURL.href} `; -export const GET = ({ site }) => { - const sitemapURL = new URL("sitemap-index.xml", site); - return new Response(getRobotsTxt(sitemapURL)); +export const GET = () => { + return new Response(getRobotsTxt()); };