diff --git a/astro.config.mjs b/astro.config.mjs index 4350070..c5416ec 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -12,6 +12,17 @@ export default defineConfig({ output: "server", adapter: node({ mode: "ssr" }), vite: { - plugins: [tailwindcss()] + plugins: [tailwindcss()], + optimizeDeps: { + // Client-island deps that are not reachable from the SSR entry graph are + // discovered mid-session, which makes Vite re-optimize and bump the browserHash. + // Every already-served island module then 504s with "Outdated Optimize Dep", + // hydration aborts, and the Solid lists on /blog, /projects and /search stay + // empty. Pre-declaring them bundles them at startup so the hash never changes + // underneath a page. Keep this list in sync with the imports of every + // src/components/*.tsx island (solid-js, @lib/utils -> clsx + tailwind-merge, + // @lib/search -> fuse.js). + include: ["solid-js", "solid-js/web", "clsx", "tailwind-merge", "fuse.js"], + }, } }) diff --git a/src/components/Blog.tsx b/src/components/Blog.tsx index 44ccbde..7a56390 100644 --- a/src/components/Blog.tsx +++ b/src/components/Blog.tsx @@ -1,7 +1,8 @@ import type { BlogPost } from "@lib/types" -import { createEffect, createSignal, For } from "solid-js" +import { createMemo, createSignal, For } from "solid-js" import ArrowCard from "@components/ArrowCard" import { cn } from "@lib/utils" +import { filterByTags } from "@lib/content" type Props = { tags: string[] @@ -10,20 +11,12 @@ type Props = { export default function Blog({ data, tags }: Props) { const [filter, setFilter] = createSignal(new Set()) - const [posts, setPosts] = createSignal([]) - createEffect(() => { - setPosts(data.filter((entry) => { - // Filter by tags - const tagMatch = Array.from(filter()).every((value) => - entry.tags.some((tag:string) => - tag.toLowerCase() === String(value).toLowerCase() - ) - ) - - return tagMatch - })) - }) + // `createMemo`, not `createEffect` + a signal: effects never run during SSR, so the + // signal stayed at its initial `[]` and the server emitted "SHOWING 0 OF 3" with an + // empty