diff --git a/middleware.ts b/middleware.ts index 838a1c0a..e78a0e1c 100644 --- a/middleware.ts +++ b/middleware.ts @@ -68,8 +68,8 @@ export const middleware = (request: NextRequest) => { }; export const config: MiddlewareConfig = { - // save compute time by skipping middleware for static and metadata files + // save compute time by skipping middleware for next.js internals and static files matcher: [ - "/((?!_next/static|_next/image|_vercel|api|static|\\.well-known|favicon.ico|icon.png|apple-icon.png|sitemap.xml|robots.txt|manifest.webmanifest|feed.xml|feed.atom).*)", + "/((?!_next/|_vercel/|api/|\\.well-known/|[^?]*\\.(?:png|jpe?g|gif|webp|avif|svg|ico|webm|mp4|ttf|woff2?|xml|atom|txt|pdf|webmanifest)).*)", ], }; diff --git a/notes/dark-mode/index.mdx b/notes/dark-mode/index.mdx index 263ed591..74cf0a63 100644 --- a/notes/dark-mode/index.mdx +++ b/notes/dark-mode/index.mdx @@ -32,13 +32,12 @@ I've written a simple implementation below, which... ...meaning that any CSS selectors beginning with `body.dark` or `body.light` will only apply when the respective mode is active. A good place to start is by separating any color rules — your background, text, links, etc. — into a different section of your CSS. Using [SASS or SCSS](https://sass-lang.com/) makes this a whole lot [easier with nesting](https://sass-lang.com/guide#topic-3) but is not required; this was written with a [KISS](https://www.youtube-nocookie.com/embed/O58A7MJfOwU?hl=en&fs=1&showinfo=1&rel=0&iv_load_policy=3) mentality. -A _very_ barebones example is embedded above ([view the source here](https://github.com/jakejarvis/dark-mode-example), or [open in a new window](https://jakejarvis.github.io/dark-mode-example/) if your browser is blocking the frame) and you can try it out on this site by clicking the 💡 lightbulb in the upper right corner of this page. You'll notice that the dark theme sticks when refreshing this page, navigating between other pages, or if you were to return to this example weeks from now. +A _very_ barebones example is embedded above ([view the source here](https://github.com/jakejarvis/dark-mode-example), or [open in a new window](/static/dark-mode/example.html) if your browser is blocking the frame) and you can try it out on this site by clicking the 💡 lightbulb in the upper right corner of this page. You'll notice that the dark theme sticks when refreshing this page, navigating between other pages, or if you were to return to this example weeks from now. --- diff --git a/public/static/dark-mode/example.html b/public/static/dark-mode/example.html new file mode 100644 index 00000000..2f9ff0ba --- /dev/null +++ b/public/static/dark-mode/example.html @@ -0,0 +1,131 @@ + + + + + + Welcome to the dark side 🌓 + + + +

Welcome to the dark side 🌓

+ + + +

View the source code or read the post.

+ + + +