chore(deps): upgrade tailwind to v4 via vite plugin
Replace @astrojs/tailwind with @tailwindcss/vite in the Astro config and lockfile to adopt Tailwind CSS v4 and simplify the build setup. Also update Markdown site content with current SpaghetAI/MarvinBlade infrastructure details.
This commit is contained in:
1 parent
ac545c4668
commit
3fef5d378e
26 files changed
+1705
-3431
No files matched your search
@@ -0,0 +1,147 @@
|
||||
# Task Handoff — Search Function Fix (Astro / Spaghet.io)
|
||||
|
||||
## TL;DR
|
||||
|
||||
The `/search` page had **two** root causes, both now fixed and verified in the
|
||||
working tree. `astro check` → 0 errors, `npm test` → 11/11 pass,
|
||||
`astro build` → exit 0. Remaining work is **browser confirmation** and a
|
||||
**separate production-deploy problem** (see "Not done").
|
||||
|
||||
Complexity: **Standard** track. Repo: brownfield Astro 7.3.8 + Solid 1.9.17,
|
||||
`output: "server"` with `@astrojs/node` SSR adapter.
|
||||
|
||||
## Root causes found
|
||||
|
||||
1. **`?search=` URL param was never read.** `src/pages/search/index.astro`
|
||||
used `new URL(typeof window !== 'undefined' ? window.location.href :
|
||||
'http://localhost')`. Astro frontmatter runs on the **server**, so `window`
|
||||
is always undefined → it always fell back to a query-less localhost URL.
|
||||
Refresh, share, and back/forward silently produced an empty search.
|
||||
Fixed to `Astro.url.searchParams.get("search") ?? ""`.
|
||||
|
||||
2. **Zero-match queries rendered nothing at all.** The result block was gated
|
||||
on `query().length >= 2 && (posts.length > 0 || projects.length > 0)`, so a
|
||||
search with no hits showed a blank page — indistinguishable from a crash.
|
||||
Added explicit "No results for '…'" and "Keep typing…" states.
|
||||
|
||||
3. (Bonus, real) **Full markdown `body` was serialized into the island's
|
||||
`props`** — 21,873 chars / 43,572-byte page — while the filter only matched
|
||||
title/summary/tags. Removed.
|
||||
|
||||
## ⚠️ The trap that caused a 500 (read this before touching Search.tsx)
|
||||
|
||||
`output: "server"` + `client:load` means the **Solid component body executes on
|
||||
the server**, and Solid also runs `onCleanup` during **server teardown**. So:
|
||||
|
||||
- Top-level `window.addEventListener(...)` in the body → `ReferenceError:
|
||||
window is not defined` → 500.
|
||||
- `window.removeEventListener(...)` inside `onCleanup` → **also** throws on the
|
||||
server. This was my own regression and is why `/search` briefly 500'd.
|
||||
|
||||
Rules now encoded in the file:
|
||||
- Browser API access lives in `onMount` (never runs on server), **or** is
|
||||
gated by the `popStateBound` flag inside `onCleanup`.
|
||||
- `syncUrl()` has a `typeof window === "undefined"` guard.
|
||||
- Also: JSX text is assigned via `textContent`, so HTML entities like
|
||||
`—` render literally. Use real `—` characters in JSX text.
|
||||
|
||||
|
||||
## Files changed / added
|
||||
|
||||
| File | Change |
|
||||
|---|---|
|
||||
| `src/lib/search.ts` **(new)** | Fuse.js 7.1.0 wrapper: `createSearcher`, `runSearch`, `partitionByCollection`, `MIN_QUERY_LENGTH = 2`, weighted keys title .4 / tags .35 / summary .25, `threshold: 0.4`, `ignoreLocation: true` |
|
||||
| `src/lib/content.ts` **(new)** | `toSearchEntry(entry)` — single mapper shared by every page that renders cards |
|
||||
| `src/lib/types.ts` | Added `SearchEntry` + `CardEntry` union (source of truth for the type) |
|
||||
| `src/pages/search/index.astro` | `Astro.url.searchParams` fix; emits slim `entries` prop |
|
||||
| `src/components/Search.tsx` | Uses searcher; `searched` state flag; empty/short-query states; `syncUrl` (replaceState on debounce, pushState on submit); `onPopState` restore; `onMount` + `popStateBound`; `ReturnType<typeof setTimeout>` instead of `NodeJS.Timeout` |
|
||||
| `src/components/ArrowCard.tsx` | Dropped `any` → `CardEntry`; resolves `collection` from entry **or** prop; `slug` fallback |
|
||||
| `src/pages/index.astro` | Uses `toSearchEntry` (was emitting legacy `$id` + `Date`) |
|
||||
| `src/lib/__tests__/search.test.ts` **(new)** | 11 unit tests |
|
||||
| `vitest.config.ts` **(new)** | node env + `@lib`-style aliases mirroring tsconfig |
|
||||
| `package.json` | Added `"test": "vitest run"`, `"test:watch": "vitest"` |
|
||||
| `.clinerules/tool-catalog.md` **(new)** | Records the only real tools here (`editor`, `read_files`, `run_commands`, `search_codebase`, `ask_question`, `skills`, `fetch_web_content`, `searxng-*`). `.clinerules` is gitignored, so this is local-only. |
|
||||
|
||||
## Verified evidence
|
||||
|
||||
```
|
||||
search?search=astro -> query prop [0,"astro"] ssr input value="astro" (was [0,""] / "")
|
||||
island props -> 3,576 chars (was 21,873)
|
||||
/search page -> 25,304 bytes (was 43,572)
|
||||
/search / /blog -> HTTP 200, no ReferenceError in server log
|
||||
homepage card hrefs -> /blog/01-…, /projects/astro-profile (no 404 regression)
|
||||
astro check -> 0 errors, 0 warnings
|
||||
npm test -> 11 passed
|
||||
astro build -> exit 0
|
||||
bundle Search.DxvATC7F.js contains "No results for", "Keep typing",
|
||||
pushState, replaceState, popstate, Fuse 7.1.0
|
||||
```
|
||||
|
||||
## How to reproduce the verification
|
||||
|
||||
```bash
|
||||
cd "/home/spaghet/Documents/Spaghet.io"
|
||||
npx astro build
|
||||
node -e "import('./dist/server/entry.mjs').then(m=>m.startServer())" &
|
||||
# fetch /search?search=astro, then parse the <astro-island props="..."> attribute
|
||||
# (decode " -> " and JSON.parse; keys should be [query, entries])
|
||||
```
|
||||
|
||||
|
||||
## NOT done — remaining work
|
||||
|
||||
1. **Browser-level confirmation (do this first).** No `jsdom`/`happy-dom`/
|
||||
`playwright` is installed, so hydration and typing behaviour were verified
|
||||
only indirectly (SSR markup, decoded props, module resolution, bundle
|
||||
greps) — **not** by executing client JS. Load `/search`, type `astro`,
|
||||
confirm results render, confirm the URL gains `?search=astro`, press
|
||||
back/forward, and search `zzzq` to see "No results for 'zzzq'".
|
||||
|
||||
2. **Production is a different, stale build — SEPARATE ISSUE.**
|
||||
`spaghet.io/search` → 307 → `home.spaghet.io/search/`, which serves
|
||||
`Search.JqbiLQV3.js` (Fuse-based, single `data` prop, **8** docs — including
|
||||
`02-appwrite-nginx-reverse-proxy-fix` and an `appwrite` project that no
|
||||
longer exist in this repo). The local build emits `Search.DxvATC7F.js` with
|
||||
an `entries` prop. Deploying `main` changes live behaviour; review the diff
|
||||
first. No Dockerfile/CI in-repo — deploy is Gitea → GitHub → self-hosted →
|
||||
NGINX (see README).
|
||||
|
||||
3. **Unrelated pre-existing dirt in the tree.** `src/styles/global.css`,
|
||||
`tailwind.config.mjs`, `public/js/theme.js` and `astro.config.mjs` already
|
||||
carried an uncommitted Tailwind v3→v4 migration before this task.
|
||||
`tailwind.config.mjs` is orphaned under v4 unless `@config` is used.
|
||||
**Do not bundle that into the search commit** without asking.
|
||||
|
||||
4. **Body-content search was deliberately dropped** with the payload trim.
|
||||
If wanted, add an API route (`src/pages/api/*`) — do not re-inflate island
|
||||
props.
|
||||
|
||||
5. Consider whether `threshold: 0.4` fuzzy matching is too loose for short
|
||||
queries (it now matches typos, e.g. `websit` → match). Tune in
|
||||
`src/lib/search.ts`.
|
||||
|
||||
## Suggested commit (NOT executed)
|
||||
|
||||
```
|
||||
fix(search): read SSR query param, add empty states, slim island payload
|
||||
|
||||
- Use Astro.url.searchParams instead of window (unavailable in SSR) so
|
||||
?search= deep links, refreshes and back/forward restore results
|
||||
- Render explicit "No results" / "Keep typing" states instead of blank page
|
||||
- Move search logic to src/lib/search.ts with Fuse.js fuzzy matching
|
||||
- Stop serializing markdown bodies into island props (43.5 KB -> 25.3 KB)
|
||||
- Guard browser APIs behind onMount; onCleanup previously threw during SSR
|
||||
teardown and 500'd /search
|
||||
- Add 11 vitest unit tests + test script + vitest.config.ts aliases
|
||||
```
|
||||
|
||||
Delete this file once the handoff is consumed.
|
||||
|
||||
Caveats learned the hard way:
|
||||
- `astro dev` backgrounded from the agent shell gets **reaped between tool
|
||||
calls**; starting the built server and curling it in the *same* command works.
|
||||
- `astro dev` may print "Another astro dev server is already running" →
|
||||
`npx astro dev stop`.
|
||||
- `node -e "import('./dist/server/entry.mjs')"` alone exits silently — the
|
||||
adapter only listens if you call `startServer()`.
|
||||
- `vitest` 5 removed the `basic` reporter; use default or `dot`.
|
||||
+6
-3
@@ -1,14 +1,17 @@
|
||||
import { defineConfig } from "astro/config"
|
||||
import mdx from "@astrojs/mdx"
|
||||
import sitemap from "@astrojs/sitemap"
|
||||
import tailwind from "@astrojs/tailwind"
|
||||
import solidJs from "@astrojs/solid-js"
|
||||
import node from "@astrojs/node"
|
||||
import tailwindcss from "@tailwindcss/vite"
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
site: "https://spaghet.io",
|
||||
integrations: [mdx(), sitemap(), solidJs(), tailwind({ applyBaseStyles: false })],
|
||||
integrations: [mdx(), sitemap(), solidJs()],
|
||||
output: "server",
|
||||
adapter: node({ mode: "ssr" })
|
||||
adapter: node({ mode: "ssr" }),
|
||||
vite: {
|
||||
plugins: [tailwindcss()]
|
||||
}
|
||||
})
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Starting Astro migration process..."
|
||||
|
||||
# Step 1: Update dependencies
|
||||
echo "Updating Astro and related packages..."
|
||||
npm install astro@latest
|
||||
npm install @astrojs/mdx@latest
|
||||
npm install @astrojs/tailwind@latest
|
||||
npm install @astrojs/solid-js@latest
|
||||
npm install @astrojs/sitemap@latest
|
||||
|
||||
# Step 2: Check for any build issues
|
||||
echo "Checking if project builds correctly..."
|
||||
npm run build
|
||||
|
||||
# Step 3: Run tests to ensure everything works
|
||||
echo "Running tests..."
|
||||
npm test
|
||||
|
||||
echo "Migration process completed. Please review any warnings or errors above."
|
||||
Generated
+595
-3276
File diff suppressed because it is too large.
Load diff
+4
-3
@@ -10,6 +10,8 @@
|
||||
"preview": "dotenv -e .env -- astro preview",
|
||||
"preview:network": "dotenv -e .env -- astro dev --host",
|
||||
"astro": "astro",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix"
|
||||
},
|
||||
@@ -20,21 +22,20 @@
|
||||
"@astrojs/rss": "^4.0.19",
|
||||
"@astrojs/sitemap": "^3.7.4",
|
||||
"@astrojs/solid-js": "^7.0.2",
|
||||
"@astrojs/tailwind": "^6.0.2",
|
||||
"@solidjs/testing-library": "^0.8.10",
|
||||
"@tailwindcss/typography": "^0.5.10",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"astro": "^7.3.8",
|
||||
"clsx": "^2.1.0",
|
||||
"fuse.js": "^7.0.0",
|
||||
"notenv": "^2.0.3",
|
||||
"npm": "^11.5.2",
|
||||
"rehype-stringify": "^10.0.1",
|
||||
"remark": "^15.0.1",
|
||||
"remark-rehype": "^11.1.2",
|
||||
"sharp": "^0.35.5",
|
||||
"solid-js": "^1.8.15",
|
||||
"tailwind-merge": "^3.7.0",
|
||||
"tailwindcss": "^3.4.19",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.3.4",
|
||||
|
||||
+9
-10
@@ -1,6 +1,7 @@
|
||||
function changeTheme() {
|
||||
const element = document.documentElement
|
||||
const theme = element.classList.contains("dark") ? "light" : "dark"
|
||||
console.log("Changing theme to:", theme)
|
||||
|
||||
const css = document.createElement("style")
|
||||
|
||||
@@ -23,6 +24,8 @@ function changeTheme() {
|
||||
element.classList.remove("dark")
|
||||
}
|
||||
|
||||
console.log("Dark class present:", element.classList.contains("dark"))
|
||||
|
||||
window.getComputedStyle(css).opacity
|
||||
document.head.removeChild(css)
|
||||
localStorage.theme = theme
|
||||
@@ -50,17 +53,13 @@ function preloadTheme() {
|
||||
localStorage.theme = theme
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
function initializeThemeButtons() {
|
||||
const headerThemeButton = document.getElementById("header-theme-button")
|
||||
const drawerThemeButton = document.getElementById("drawer-theme-button")
|
||||
headerThemeButton?.addEventListener("click", changeTheme)
|
||||
drawerThemeButton?.addEventListener("click", changeTheme)
|
||||
// Use event delegation to avoid duplicate listeners on navigation
|
||||
document.addEventListener("click", (event) => {
|
||||
const target = event.target.closest("#header-theme-button, #drawer-theme-button");
|
||||
if (target) {
|
||||
changeTheme();
|
||||
}
|
||||
|
||||
document.addEventListener("astro:after-swap", initializeThemeButtons)
|
||||
initializeThemeButtons()
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("astro:after-swap", preloadTheme)
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import { formatDate } from "@lib/utils"
|
||||
import type { BlogPost, Project } from "@lib/types"
|
||||
import type { CardEntry } from "@lib/types"
|
||||
|
||||
type Props = {
|
||||
entry: BlogPost | Project | any
|
||||
entry: CardEntry
|
||||
collection?: string
|
||||
pill?: boolean
|
||||
}
|
||||
|
||||
export default function ArrowCard({entry, pill, collection}: Props) {
|
||||
const id = entry.id || entry.$id
|
||||
// Search results carry their own `collection`; listing pages pass it in
|
||||
// as a prop. Both paths resolve to the same route shape.
|
||||
const resolvedCollection = "collection" in entry ? entry.collection : collection
|
||||
const id = "slug" in entry ? entry.slug : entry.id
|
||||
return (
|
||||
<a href={`/${collection === 'blog' ? 'blog' : 'projects'}/${id}`} class="group p-4 gap-3 flex items-center border border-spaghetti-brown rounded-lg hover:bg-spaghetti-red/5 hover:dark:bg-spaghetti-cream/10 dark:border-spaghetti-dark-cream/20 transition-colors duration-300 ease-in-out">
|
||||
<a href={`/${resolvedCollection === 'blog' ? 'blog' : 'projects'}/${id}`} class="group p-4 gap-3 flex items-center border border-spaghetti-brown rounded-lg hover:bg-spaghetti-red/5 hover:dark:bg-spaghetti-cream/10 dark:border-spaghetti-dark-cream/20 transition-colors duration-300 ease-in-out">
|
||||
<div class="w-full group-hover:text-spaghetti-red group-hover:dark:text-spaghetti-dark-cream blend">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
{pill &&
|
||||
|
||||
+97
-40
@@ -1,60 +1,105 @@
|
||||
import type { BlogPost, Project } from "@lib/types"
|
||||
import { createEffect, createSignal, onCleanup } from "solid-js"
|
||||
import { createEffect, createSignal, onCleanup, onMount } from "solid-js"
|
||||
import ArrowCard from "@components/ArrowCard"
|
||||
import {
|
||||
createSearcher,
|
||||
partitionByCollection,
|
||||
runSearch,
|
||||
MIN_QUERY_LENGTH,
|
||||
type SearchEntry,
|
||||
} from "@lib/search"
|
||||
|
||||
type Props = {
|
||||
query?: string
|
||||
posts?: BlogPost[]
|
||||
projects?: Project[]
|
||||
/** Slim searchable entries serialized by src/pages/search/index.astro */
|
||||
entries?: SearchEntry[]
|
||||
}
|
||||
|
||||
const QUERY_PARAM = "search"
|
||||
const DEBOUNCE_MS = 300
|
||||
|
||||
export default function Search(props: Props) {
|
||||
const [query, setQuery] = createSignal(props.query || "")
|
||||
const [results, setResults] = createSignal<{ posts: BlogPost[], projects: Project[] }>({ posts: [], projects: [] })
|
||||
const [results, setResults] = createSignal<{ posts: SearchEntry[]; projects: SearchEntry[] }>({ posts: [], projects: [] })
|
||||
const [searched, setSearched] = createSignal(false)
|
||||
const [loading, setLoading] = createSignal(false)
|
||||
const [error, setError] = createSignal<string | null>(null)
|
||||
|
||||
// Debounce timeout reference
|
||||
let debounceTimeout: NodeJS.Timeout | null = null
|
||||
// Build the fuzzy index once per hydration; keystrokes reuse it.
|
||||
const searcher = createSearcher(props.entries || [])
|
||||
|
||||
// Debounce timer reference (browser-safe type; `NodeJS.Timeout` leaks
|
||||
// Node types into a client component).
|
||||
let debounceTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
/**
|
||||
* Mirror the active query into the URL so refresh, back/forward and sharing
|
||||
* all restore the same result set. `replaceState` keeps history tidy while
|
||||
* typing; explicit submits push a real entry.
|
||||
*/
|
||||
const syncUrl = (q: string, push = false) => {
|
||||
// Guard: this component is SSR'd, and history APIs are unavailable there.
|
||||
if (typeof window === "undefined") return
|
||||
const url = new URL(window.location.href)
|
||||
if (q.trim().length >= MIN_QUERY_LENGTH) {
|
||||
url.searchParams.set(QUERY_PARAM, q)
|
||||
} else {
|
||||
url.searchParams.delete(QUERY_PARAM)
|
||||
}
|
||||
if (push) {
|
||||
window.history.pushState({}, "", url.toString())
|
||||
} else {
|
||||
window.history.replaceState({}, "", url.toString())
|
||||
}
|
||||
}
|
||||
|
||||
// Client-side search through provided data
|
||||
createEffect(() => {
|
||||
if (query().length < 2) {
|
||||
const q = query()
|
||||
|
||||
if (q.trim().length < MIN_QUERY_LENGTH) {
|
||||
if (debounceTimer) clearTimeout(debounceTimer)
|
||||
setResults({ posts: [], projects: [] })
|
||||
setSearched(false)
|
||||
setLoading(false)
|
||||
setError(null)
|
||||
return
|
||||
}
|
||||
|
||||
// Clear previous timeout
|
||||
if (debounceTimeout) {
|
||||
clearTimeout(debounceTimeout)
|
||||
}
|
||||
if (debounceTimer) clearTimeout(debounceTimer)
|
||||
|
||||
// Set new debounce timeout
|
||||
debounceTimeout = setTimeout(() => {
|
||||
setLoading(true)
|
||||
debounceTimer = setTimeout(() => {
|
||||
try {
|
||||
const q = query().toLowerCase()
|
||||
const filteredPosts = (props.posts || []).filter(post =>
|
||||
post.title.toLowerCase().includes(q) ||
|
||||
post.summary.toLowerCase().includes(q) ||
|
||||
post.tags.some(tag => tag.toLowerCase().includes(q))
|
||||
)
|
||||
const filteredProjects = (props.projects || []).filter(project =>
|
||||
project.title.toLowerCase().includes(q) ||
|
||||
project.summary.toLowerCase().includes(q) ||
|
||||
project.tags.some(tag => tag.toLowerCase().includes(q))
|
||||
)
|
||||
setResults({ posts: filteredPosts, projects: filteredProjects })
|
||||
const matched = runSearch(searcher, q)
|
||||
setResults(partitionByCollection(matched))
|
||||
setSearched(true)
|
||||
setError(null)
|
||||
// Keep the address bar in sync so the current results are shareable
|
||||
// and survive a refresh.
|
||||
syncUrl(q)
|
||||
} catch (err) {
|
||||
console.error("Search error:", err)
|
||||
setResults({ posts: [], projects: [] })
|
||||
setSearched(true)
|
||||
setError("Search failed. Please try again.")
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, 300) // 300ms debounce delay
|
||||
}, DEBOUNCE_MS)
|
||||
})
|
||||
|
||||
// Restore the query when the user navigates with browser back/forward.
|
||||
const onPopState = () => {
|
||||
setQuery(new URL(window.location.href).searchParams.get(QUERY_PARAM) || "")
|
||||
}
|
||||
|
||||
// IMPORTANT: this component is SSR'd (output: "server" + client:load). The
|
||||
// component body runs on the server AND Solid runs onCleanup during server
|
||||
// teardown, while onMount never runs on the server. So every browser-API
|
||||
// touchpoint must either live in onMount or be gated by `popStateBound`.
|
||||
let popStateBound = false
|
||||
onMount(() => {
|
||||
window.addEventListener("popstate", onPopState)
|
||||
popStateBound = true
|
||||
})
|
||||
|
||||
const onInput = (e: Event) => {
|
||||
@@ -64,21 +109,18 @@ export default function Search(props: Props) {
|
||||
|
||||
const handleSubmit = (e: Event) => {
|
||||
e.preventDefault()
|
||||
// Prevent page refresh by using client-side navigation
|
||||
if (query().length >= 2) {
|
||||
// Search will automatically trigger due to createEffect
|
||||
// Update URL without full page reload
|
||||
const newUrl = `${window.location.pathname}?search=${encodeURIComponent(query())}`
|
||||
window.history.pushState({}, "", newUrl)
|
||||
// Dispatch custom event to update search results (removed for now - not needed with createEffect)
|
||||
// Never let the browser do a full page reload; the createEffect re-runs
|
||||
// the search and syncUrl keeps the address bar shareable.
|
||||
if (query().trim().length >= MIN_QUERY_LENGTH) {
|
||||
syncUrl(query(), true)
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup debounce timeout on component unmount
|
||||
// Cleanup the debounce timer (safe on server) and the history listener,
|
||||
// which is only ever bound in the browser.
|
||||
onCleanup(() => {
|
||||
if (debounceTimeout) {
|
||||
clearTimeout(debounceTimeout)
|
||||
}
|
||||
if (debounceTimer) clearTimeout(debounceTimer)
|
||||
if (popStateBound) window.removeEventListener("popstate", onPopState)
|
||||
})
|
||||
|
||||
return (
|
||||
@@ -100,7 +142,22 @@ export default function Search(props: Props) {
|
||||
</form>
|
||||
{error() && <div class="mt-4 text-red-500">{error()}</div>}
|
||||
{loading() && <div class="mt-4">Searching...<span class="ml-2 animate-spin">⏳</span></div>}
|
||||
{(query().length >= 2 && (results().posts.length > 0 || results().projects.length > 0)) && (
|
||||
{!loading() && !error() && !searched() && query().trim().length > 0 && query().trim().length < MIN_QUERY_LENGTH && (
|
||||
<div class="mt-4 text-sm uppercase text-spaghetti-brown/70 dark:text-spaghetti-dark-cream/70">
|
||||
Keep typing — search needs at least {MIN_QUERY_LENGTH} characters
|
||||
</div>
|
||||
)}
|
||||
{!loading() && !error() && searched() && results().posts.length + results().projects.length === 0 && (
|
||||
<div class="mt-12">
|
||||
<div class="text-sm uppercase mb-2">
|
||||
No results for {`'${query()}'`}
|
||||
</div>
|
||||
<div class="text-sm text-spaghetti-brown/70 dark:text-spaghetti-dark-cream/70">
|
||||
Try a shorter or more general keyword — titles, tags and summaries are all searchable.
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{(searched() && (results().posts.length > 0 || results().projects.length > 0)) && (
|
||||
<div class="mt-12">
|
||||
<div class="text-sm uppercase mb-2">
|
||||
Found {results().posts.length + results().projects.length} results for {`'${query()}'`}
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
---
|
||||
title: "Running AI From My Own Computers: Two Servers, Two Very Different Jobs"
|
||||
summary: "How I split my home servers into one that stores everything and one that thinks — in plain language, with the numbers, the mistakes I made, and how you could start the same thing much smaller."
|
||||
date: 2026-11-03
|
||||
tags: ["Homelab", "Unraid", "Storage", "Backup", "Docker", "Local AI", "NVIDIA"]
|
||||
draft: false
|
||||
template: "default"
|
||||
featured: true
|
||||
---
|
||||
|
||||
## The problem I wanted to solve
|
||||
|
||||
I want to run AI tools on my own computers. Not because it is cheaper — it usually
|
||||
isn't, once you count the hardware and the electricity — but because half of what I want
|
||||
to search through is my own paperwork: tax documents, contracts, notes, old projects, my
|
||||
family's photo library. Uploading all of that to someone else's server just to ask one
|
||||
question about it is not a trade I want to make by default.
|
||||
|
||||
The goal, in one sentence:
|
||||
|
||||
> Ask questions about my own files, and get an answer from a program running inside my
|
||||
> own house.
|
||||
|
||||
## Why that turned out to be hard
|
||||
|
||||
This single sentence needs two opposite kinds of machine.
|
||||
|
||||
**Holding a lot of data safely** wants big, cheap, slow hard drives, and protection
|
||||
against those drives dying.
|
||||
|
||||
**Thinking fast** wants enormous amounts of very expensive, very fast memory, plus a
|
||||
graphics card.
|
||||
|
||||
A computer that is excellent at both does not exist at a sane price. It would either cost
|
||||
a great deal or be bad at one of the two jobs. So I stopped trying to build one and split
|
||||
the jobs across two machines:
|
||||
|
||||
- **MarvinBlade** — the machine that *remembers*. It holds the files and runs the
|
||||
everyday services.
|
||||
- **SpaghetAI** — the machine that *thinks*. It holds memory and graphics power for the
|
||||
AI work, and almost no storage of its own.
|
||||
|
||||
Neither one does its job without the other, and the connection between them is where the
|
||||
trouble lives. I'll get to that.
|
||||
|
||||
## A few words before the numbers
|
||||
|
||||
If you don't do this for a living, here is the vocabulary this post needs.
|
||||
|
||||
| Word | What it means here |
|
||||
|---|---|
|
||||
| **Storage** | Hard drives. Big, cheap, slow. Where files sit when nothing is using them. |
|
||||
| **Memory (RAM)** | Fast working space. Expensive, and it forgets everything when the power goes out. Where data goes while it is actively in use. |
|
||||
| **Graphics card (GPU)** | A video card, which turns out to be very good at the arithmetic AI needs. |
|
||||
| **Card memory (VRAM)** | The fast space built into the graphics card. Faster again, and far more expensive. |
|
||||
| **Container** | One program packaged together with everything it needs to run, so it can be started, stopped, or updated without disturbing the others. |
|
||||
| **Protection drive (parity)** | An extra drive holding repair information, so that if a normal drive dies you can rebuild it from the rest. |
|
||||
|
||||
One analogy carries most of this post. Think of a kitchen:
|
||||
|
||||
- **Storage is the pantry.** Lots of room, and you have to get up and walk to it.
|
||||
- **Memory is the counter.** Much smaller, and everything you are working on right now
|
||||
has to be on it.
|
||||
- **Card memory is the cutting board.** The smallest and dearest space, and the thing
|
||||
you are actively working on has to be on it at the moment the knife comes down.
|
||||
|
||||
Anything you use often wants to be closer to the knife. Nearly every decision below is
|
||||
some version of that sentence.
|
||||
|
||||
## Side by side
|
||||
|
||||
| | **MarvinBlade** — remembers | **SpaghetAI** — thinks |
|
||||
|---|---|---|
|
||||
| Job | Holds everything, runs everyday services | Runs the AI work |
|
||||
| Case | Cisco rack server | Dell rack server |
|
||||
| Memory | 128 GB | **768 GB** |
|
||||
| Storage | **258 TB** across 30 hard drives | 960 GB of solid-state, no drive array |
|
||||
| If a drive dies | Covered by two protection drives | Covered by nothing, on purpose |
|
||||
| Graphics | 1 ordinary card (5 GB) | **2 cards, 40 GB between them** |
|
||||
| Programs running | 81 | 5 |
|
||||
| Age | About 8 years | Newer |
|
||||
|
||||
Both run Unraid, a Linux built for exactly this kind of pile of mismatched drives. Same
|
||||
operating system, same era of hardware, opposite design goals.
|
||||
|
||||
## The work: MarvinBlade, the machine that remembers
|
||||
|
||||
MarvinBlade is an eight-year-old server whose whole job is to hold things and keep
|
||||
holding them.
|
||||
|
||||
It has **258 terabytes of storage spread across 30 hard drives**, with about 117 TB
|
||||
still free. The drives are a mix of sizes — some 4 TB, most 8 TB, a few 16 TB — which is
|
||||
normally a problem, because most storage systems want all their drives to match.
|
||||
|
||||
Two of the thirty drives are **protection drives**. They don't hold your files; they hold
|
||||
the arithmetic needed to rebuild the others. Because there are two of them, this machine
|
||||
can lose **two hard drives at the same time** and still have everything.
|
||||
|
||||
That sounds like enough, and for a long time I assumed it was the whole story. It isn't.
|
||||
I'll come back to that in the section about what actually worries me now.
|
||||
|
||||
### What it runs
|
||||
|
||||
Eighty-one separate programs live on this machine. The full list is on my
|
||||
[Home System project page](/projects/home-system/), but grouped, it's:
|
||||
|
||||
- **Media** — a streaming library for video and music and photos, so I can watch our
|
||||
own files from any screen in the house.
|
||||
- **Records** — a photo library, scanned documents, finances, groceries.
|
||||
- **One sign-in** — a single login page in front of everything worth protecting, so
|
||||
there is one place to turn access off.
|
||||
- **Documents** — a file-sync and office suite that replaces the Google-style tools.
|
||||
- **Automations** — the plumbing that makes the first four groups talk to each other.
|
||||
|
||||
For a while I wanted this machine to also do AI work. It has a basic graphics card in it,
|
||||
and it can run small models, but it kept hitting the same wall: a model that fits in
|
||||
memory is a model that runs slowly, and a model big enough to be genuinely useful doesn't
|
||||
fit. That's what led to the second machine.
|
||||
|
||||
## The work: SpaghetAI, the machine that thinks
|
||||
|
||||
This is the one people find strange, and I understand why.
|
||||
|
||||
SpaghetAI has **768 GB of memory and two graphics cards with 40 GB of their own memory
|
||||
between them**. It has **no hard drives at all** — just about a terabyte of solid-state
|
||||
storage for the programs themselves.
|
||||
|
||||
And when I looked at it recently, it was **using only 77 of those 768 GB.** That is 10%
|
||||
of the memory in the machine. So the obvious question is: why buy 768 GB for 77 GB of
|
||||
work?
|
||||
|
||||
### Why 768 GB of memory for 77 GB of work
|
||||
|
||||
Back to the kitchen. The counter looks empty, but the counter is empty **because I
|
||||
already put everything on it.** Nothing is being cooked yet.
|
||||
|
||||
Here's what that memory is actually for:
|
||||
|
||||
- **The model has to be on the counter already.** An AI model is a very large file. If the
|
||||
machine has to go fetch it from a drive each time you ask something, an answer that
|
||||
should take two seconds takes two minutes. So the models are loaded and left there,
|
||||
waiting. That is most of the 77 GB that is currently used.
|
||||
- **Long conversations eat memory fast.** Reading one page is cheap. Reading five hundred
|
||||
pages at once is not, and the cost climbs faster than the page count does. The rest of
|
||||
the 768 GB is there so the answer to "can you read all of these?" is always yes.
|
||||
- **Searching across documents wants to be instant.** Finding the passage that answers a
|
||||
question means holding an index of everything searchable in fast memory. On a hard
|
||||
drive, that same search is slow enough that you stop doing it.
|
||||
|
||||
And here is the number that convinced me the design is right rather than wasteful. At the
|
||||
same moment that memory showed 10% used, **both graphics cards were nearly full — about
|
||||
19 of their 20 GB in use each — while doing nothing at all.**
|
||||
|
||||
That is the machine at rest. The models are loaded, resident, and waiting. Nothing is
|
||||
being asked of them. It isn't underused; it is **pre-loaded**.
|
||||
|
||||
### What I actually built on top of it
|
||||
|
||||
Five programs, which is a much shorter list than the hardware suggests. That's
|
||||
intentional — one thin layer doing the thinking, and nothing else.
|
||||
|
||||
| Program | What it does for me |
|
||||
|---|---|
|
||||
| **strata** | The main one. I ask a question in a web page; it searches my documents and answers with sources I can click. |
|
||||
| **LocalAI_Worker** | A helper that lets the first machine ask this one for help when a job is too big for it. |
|
||||
| **Docling-Serve** | Turns a PDF or a scan into clean, readable text — the step before anything can be searched. |
|
||||
| **appapi-harp** | Hooks the AI into the document suite, so the same answers appear where I already work. |
|
||||
| **open-terminal** | A controlled command line the AI can use, for jobs that aren't document questions. |
|
||||
|
||||
The piece I'd point at if you only remember one thing: **the two machines work together as
|
||||
one AI service.** MarvinBlade already ran the AI program for my chat interface and my
|
||||
search stack. When SpaghetAI came along, it simply joined that same setup as a helper.
|
||||
Small and easy jobs still run on the old card; jobs that need real graphics power go to the
|
||||
new one. **Nothing about the front door changed** — the same search box, the same chat
|
||||
window. It just got a stronger option behind it.
|
||||
|
||||
If you're wondering why the PDF converter matters that much: it's the unglamorous half of
|
||||
the whole project. Getting a model to answer well is mostly a matter of getting its
|
||||
reading material into clean text first. Most of my early frustration came from models
|
||||
giving confident nonsense, and most of that nonsense traced back to a badly converted
|
||||
document rather than a bad model.
|
||||
|
||||
## The outcome
|
||||
|
||||
It works. I can open a web page, ask a question in plain English about documents that
|
||||
exist only inside my house, and get an answer with links back to the pages it came from.
|
||||
Photos, PDFs, scans, notes. Nothing left my network to do it.
|
||||
|
||||
The honest limits, because they matter more than the wins:
|
||||
|
||||
- **It is not faster than a cloud service.** My setup is slower than the big commercial
|
||||
ones, and the models I can run are less capable than the ones I'd use for a hard
|
||||
reasoning problem. I still use those.
|
||||
- **Speed comes from the pre-loading, not the hardware.** Warm, it's fine. Cold, it's
|
||||
slow — and how cold it goes depends entirely on the problem in the next section.
|
||||
- **It takes upkeep.** Updates break things, and drives die. This is the part people
|
||||
underestimate when they see the exciting spec sheet.
|
||||
|
||||
What I get for that is not speed or capability. It's that the answer is the same one
|
||||
whether or not I have internet, and the material it read never left the building.
|
||||
|
||||
## The mistake I made, and would make again differently
|
||||
|
||||
Here is the part this post exists to warn you about.
|
||||
|
||||
SpaghetAI has no hard drives. So where do its model files — the multi-gigabyte ones —
|
||||
live?
|
||||
|
||||
**On MarvinBlade.** The AI machine reaches across the network, to the storage machine,
|
||||
to load its own brain.
|
||||
|
||||
```text
|
||||
MarvinBlade SpaghetAI
|
||||
┌──────────────────┐ ┌────────────────────┐
|
||||
│ holds all the │ │ does the thinking │
|
||||
│ files, and all │◄──────►│ 40 GB of graphics │
|
||||
│ the model files │ network│ memory, waiting │
|
||||
└──────────────────┘ └────────────────────┘
|
||||
▲ ▲
|
||||
│ │
|
||||
if this goes down, this can't
|
||||
everything does start up
|
||||
```
|
||||
|
||||
The consequences, in order of how much they annoy me:
|
||||
|
||||
1. **The AI machine cannot start over.** Restart it and it needs a network trip to reload
|
||||
its models. Fast if the models are already in memory; slow if they aren't.
|
||||
2. **They fail together.** If MarvinBlade goes down, the AI goes down with it, even
|
||||
though the expensive half of the AI stack is sitting idle two feet away with its
|
||||
graphics cards still loaded.
|
||||
3. **One power problem takes out both.** And that's the thing I actually found.
|
||||
|
||||
MarvinBlade's 30 drives don't fit inside the server case. They live in **two separate
|
||||
drive cabinets** bolted into the rack beside it, connected by cable.
|
||||
|
||||
Each cabinet has four power supplies, so it can survive one failing. Right now **two of
|
||||
the four in each cabinet are dead.** The cabinets still run — they have working supplies
|
||||
— but the *backup* is gone. A single power event now takes out most of 30 drives and both
|
||||
protection drives at once. No amount of protection survives that. Meanwhile a parity
|
||||
check was running the day I looked, which is the system quietly verifying it can still
|
||||
rebuild a drive.
|
||||
|
||||
So the lesson, which I'd give anyone building this: **protection against drive failure is
|
||||
not the same as protection against everything else.** The thing most likely to take my
|
||||
setup down isn't a dying disk. It's a power supply, a network cable, or the fact that I
|
||||
made one machine responsible for the other's ability to think.
|
||||
|
||||
Two smaller findings from the same check-up, both cheaper to fix than buying more
|
||||
capacity: the space holding all the programs is **86% full**, which is how you get an
|
||||
outage from a log file rather than a dead drive; and a spare drive passed its health
|
||||
check while quietly reporting two repaired sectors, which is the sort of thing you note
|
||||
and replace rather than ignore.
|
||||
|
||||
## Do this yourself
|
||||
|
||||
The useful thing about the design is that it's a *destination*, not a starting point. If
|
||||
you want to run this kind of thing at home, start far smaller than mine.
|
||||
|
||||
**Tier 1 — one normal PC and one decent graphics card.** A machine with 32 GB of memory
|
||||
and a card with 12 GB of its own will run a genuinely useful model, and it will do
|
||||
document search over a few thousand files comfortably. This is where you should start.
|
||||
The software is free, the learning is real, and none of it is wasted if you outgrow the
|
||||
hardware.
|
||||
|
||||
**Tier 2 — a used workstation with 128–256 GB of memory.** This is the step that changes
|
||||
what you can ask. Bigger models, larger document sets, and services that stay up instead
|
||||
of being started when needed. Business machines go cheaply secondhand; this is the sweet
|
||||
spot.
|
||||
|
||||
**Tier 3 — split the jobs, which is where I am.** A storage machine and a thinking
|
||||
machine, once you have enough of both to care about them failing separately.
|
||||
|
||||
Two rules of thumb I'd give myself five years ago:
|
||||
|
||||
> **Buy memory before you buy storage.** Storage is cheap and easy to add later. Memory is
|
||||
> the thing that decides what you can run at all.
|
||||
|
||||
> **Only build protection for things you would hate to lose.** A media library is not the
|
||||
> same as scanned documents. Two copies beat one; three beat two, and the difference
|
||||
> between two and three is where the real cost is.
|
||||
|
||||
And one about money, because people get this wrong in both directions: this is not
|
||||
cheaper than a subscription. The hardware cost real money and the electricity is
|
||||
measurable. I'm not buying savings. I'm buying the ability to keep my paperwork at home
|
||||
and have it still be useful.
|
||||
|
||||
## What runs this site
|
||||
|
||||
This website lives on MarvinBlade as one more program in the eighty-one. I mention it
|
||||
because I had "hosted on Appwrite" written in various notes for a long time, and it isn't
|
||||
true any more — it's a plain build served by a web server on the storage box. The site
|
||||
gets built from source and served, like everything else here. I'd rather say what's
|
||||
actually running.
|
||||
|
||||
## If you take one thing from this
|
||||
|
||||
Two machines built for opposite reasons, one pipeline between them. The spec that looks
|
||||
ridiculous — 768 GB of memory running at 10% — stops looking ridiculous once you notice
|
||||
the graphics cards are 95% full and idle. The machine isn't wasting money on memory it
|
||||
doesn't need; it's holding its work in place before the work arrives.
|
||||
|
||||
And the number that matters most on either box isn't the storage count or the memory
|
||||
count. It's the cable between them, because that's the one thing neither machine can
|
||||
survive alone.
|
||||
|
||||
---
|
||||
|
||||
*Numbers are as measured on 3 November 2026 and will drift. Capacities are written in
|
||||
terabytes as the server reports them.*
|
||||
@@ -1,21 +1,93 @@
|
||||
---
|
||||
title: "Home System"
|
||||
summary: "Technology as Lifestyle - Personal Docker ecosystem with 2 Unraid servers"
|
||||
date: 2025-08-01
|
||||
tags: ["DevOps", "Docker", "Unraid", "PostgreSQL", "MariaDB", "MySQL", "MongoDB", "Redis", "Minio", "Authentik", "LDAP", "Node-RED"]
|
||||
summary: "Technology as Lifestyle — two Unraid servers: 258 TB of dual-parity storage and a 768 GB / 40 GB-VRAM GPU inference box running 86 containers between them."
|
||||
date: 2026-11-03
|
||||
tags: ["DevOps", "Docker", "Unraid", "Homelab", "NVIDIA", "LocalAI", "RAG", "Authentik", "PostgreSQL", "MariaDB", "MySQL", "MongoDB", "Redis", "Minio", "Plex", "Nextcloud", "n8n", "Node-RED", "KVM"]
|
||||
draft: false
|
||||
---
|
||||
|
||||
Designed and maintained a scalable Docker container ecosystem supporting PostgreSQL, MariaDB, MySQL, MongoDB, Redis, and Minio for high-availability applications, ensuring robust data storage, caching, and object storage solutions.
|
||||
Two Unraid 7.3.0 hosts, designed to fail differently. MarvinBlade is the storage and
|
||||
application layer — capacity and availability. SpaghetAI is the inference layer — memory
|
||||
and VRAM, with no array at all. The plain-language version of this, with the
|
||||
reasoning and the mistakes, is the blog post
|
||||
[Running AI From My Own Computers](/blog/04-marvinblade-and-spaghetai/).
|
||||
|
||||
Configured and secured authentication frameworks using Authentik, Vaultwarden, and LDAP integration, implementing zero-trust security models and access control for internal and external systems.
|
||||
## The two boxes
|
||||
|
||||
Deployed and supported proxy and API gateway solutions to enable secure, scalable, and customizable network infrastructure for internal and external applications.
|
||||
| | **MarvinBlade** | **SpaghetAI** |
|
||||
|---|---|---|
|
||||
| Role | Primary storage + application server | GPU / AI inference server |
|
||||
| Chassis | Cisco UCS C220 M4S | Dell PowerEdge R740 |
|
||||
| CPU | 2× Xeon E5-2683 v4 — 32 cores / 64 threads | 2× Xeon Silver 4214 — 24 cores / 48 threads |
|
||||
| RAM | 128 GB DDR4 ECC | 768 GB DDR4 ECC (22× 32 GB RDIMM) |
|
||||
| GPU | 1× Quadro P2000 (5 GB) | 2× RTX A4500 (40 GB total VRAM) |
|
||||
| Storage | 258 TB raw across 30 array disks, 117 TB free | 960 GB btrfs SSD pool, no array |
|
||||
| Parity | 2× 16 TB — survives two simultaneous disk failures | none, by design |
|
||||
| Filesystem | XFS throughout | btrfs |
|
||||
| Containers | 81 | 5 |
|
||||
| VMs | 2 — Home Assistant, Windows Server 2025 | none |
|
||||
|
||||
Provided end-to-end support for 30+ users utilizing the containerized applications, including troubleshooting, configuration guidance, and documentation for tools like Zammad, and Immich.
|
||||
MarvinBlade's 30 spindles live in two NetApp DS424IOM6 24-bay SAS shelves chained over
|
||||
QSFP+. Cache and hot-tier SSDs sit outside the array: 1 TB cache pool, 2 TB media pool,
|
||||
and a 720 GB Docker vDisk pool.
|
||||
|
||||
Streamlined DevOps workflows with Node-RED, custom APIs, and automation scripts, enhancing productivity for both personal and team projects.
|
||||
## What runs on them
|
||||
|
||||
Maintained and optimized containerized tools for personal and organizational use, ensuring reliability, performance, and user-friendly interfaces.
|
||||
| Category | Services |
|
||||
|---|---|
|
||||
| **Media** | Plex, Audiobookshelf, Immich (+ CUDA ML worker), Romm, Owncast, Sonarr, Radarr, Prowlarr, tdarr, SABnzbd, Deluge, Ombi |
|
||||
| **Databases** | PostgreSQL 17, PostgreSQL 17 + pgvector, MariaDB, MySQL, MongoDB 7.0, Redis, Qdrant |
|
||||
| **Identity & security** | Authentik (SSO + LDAP outpost), oauth2-proxy, Anubis, Vaultwarden, OpenBao, Pi-hole |
|
||||
| **Web & collaboration** | NGINX Proxy Manager, Nextcloud (Talk HPB, Whiteboard), Collabora CODE, OnlyOffice, DocuSeal, Reactive Resume, Gitea, spaghet-home |
|
||||
| **Automation & AI** | n8n (+ sandbox), Windmill, Node-RED, Open WebUI, LocalAI, strata, Docling-Serve, Morphic, SearXNG, Open Terminal |
|
||||
| **Gaming** | Crafty (Minecraft control panel), mcpelevator, Virtual Tabletop |
|
||||
| **Observability** | Splunk, Uptime Kuma, GoAccess, Notifiarr, autoheal |
|
||||
|
||||
Handled on-call duties for critical applications, resolving issues and minimizing downtime for users relying on the containerized ecosystem.
|
||||
Authentik fronts every service that matters, with oauth2-proxy and Anubis handling the
|
||||
apps that can't speak OIDC natively.
|
||||
|
||||
## SpaghetAI — the inference layer
|
||||
|
||||
Five containers, ~139 GB of RAM between them, both A4500s holding ~19 GB of resident
|
||||
weights each.
|
||||
|
||||
| Container | What it does | RAM |
|
||||
|---|---|---|
|
||||
| **strata** | RAG / document-search app (CUDA 13 build), port 8280 | 126 GB |
|
||||
| **LocalAI_Worker** | Distributed LocalAI worker node, gRPC 50050–50060 | 4.6 GB |
|
||||
| **Docling-Serve** | Document → Markdown/JSON parsing API, port 5001 | 4.5 GB |
|
||||
| **appapi-harp** | Nextcloud App API companion | 0.16 GB |
|
||||
| **open-terminal** | AI-accessible shell, port 8973 | 0.16 GB |
|
||||
|
||||
LocalAI runs in distributed mode: MarvinBlade hosts the orchestrator and the general
|
||||
CPU/Quadro inference, SpaghetAI joins as a GPU worker over gRPC, so heavier models get
|
||||
scheduled onto the A4500s without changing anything at the front door.
|
||||
|
||||
## The dependency between them
|
||||
|
||||
SpaghetAI has no array. Its model weights live on MarvinBlade, mounted over SMB from the
|
||||
`local_ai` share (a 2 TB cache-exclusive pool on a Crucial MX500).
|
||||
|
||||
That makes MarvinBlade a single point of failure for SpaghetAI's cold starts and model
|
||||
swaps — the GPU box can't serve anything it hasn't already loaded if the storage box
|
||||
goes down. The fix on the list is a local NVMe mirror of the hot weights so the inference
|
||||
path has its own fault boundary.
|
||||
|
||||
## Failure domains
|
||||
|
||||
Dual parity protects against two disks dying at once, which is not the most likely way
|
||||
to lose the array. Power to a shelf is. Both SAS shelves have lost PSU redundancy, and
|
||||
the array depends on that network hop between the two boxes. Durability here is a chain —
|
||||
disks, parity, shelf power, SMB — and the parity is the strongest link in it.
|
||||
|
||||
## Day-to-day operations
|
||||
|
||||
- End-to-end support for 30+ users across the containerized applications, including
|
||||
troubleshooting, configuration guidance and documentation.
|
||||
- On-call for critical services, with Uptime Kuma and Splunk providing the signal.
|
||||
- DevOps workflows automated through n8n, Windmill, Node-RED, custom APIs and Gitea
|
||||
Actions — this site itself builds and deploys through the pipeline.
|
||||
- Backup strategy layered on the dual-parity array, with separate `backup` share and
|
||||
off-array copies.
|
||||
|
||||
Specs above were measured from live telemetry on 3 November 2026 and will drift.
|
||||
@@ -0,0 +1,67 @@
|
||||
// src/lib/__tests__/content.test.ts
|
||||
import { describe, it, expect } from "vitest"
|
||||
import { byDateDesc } from "../content"
|
||||
|
||||
/**
|
||||
* Fixture factory rather than inline literals in every test: mirrors the shape
|
||||
* of an Astro content entry (id + data.date) without pulling in astro:content.
|
||||
*/
|
||||
function dated(id: string, date: string) {
|
||||
return { id, data: { date: new Date(date) } }
|
||||
}
|
||||
|
||||
describe("byDateDesc", () => {
|
||||
it("should order entries newest first when dates differ", () => {
|
||||
// Arrange: loader order (by id) is oldest -> newest.
|
||||
const entries = [
|
||||
dated("01-building-my-personal-website", "2025-08-12"),
|
||||
dated("03-spaghet-io-website-improvements", "2025-08-13"),
|
||||
dated("04-marvinblade-and-spaghetai", "2026-11-03"),
|
||||
]
|
||||
|
||||
// Act
|
||||
const sorted = [...entries].sort(byDateDesc)
|
||||
|
||||
// Assert
|
||||
expect(sorted.map((entry) => entry.id)).toEqual([
|
||||
"04-marvinblade-and-spaghetai",
|
||||
"03-spaghet-io-website-improvements",
|
||||
"01-building-my-personal-website",
|
||||
])
|
||||
})
|
||||
|
||||
it("should reverse entries that the loader already sorted oldest first by filename", () => {
|
||||
const entries = [
|
||||
dated("astro-profile", "2025-08-01"),
|
||||
dated("home-system", "2026-11-03"),
|
||||
]
|
||||
|
||||
expect([...entries].sort(byDateDesc).map((entry) => entry.id)).toEqual([
|
||||
"home-system",
|
||||
"astro-profile",
|
||||
])
|
||||
})
|
||||
|
||||
it("should break ties on id when two entries share the same date", () => {
|
||||
// Arrange: identical dates make the date comparison return 0.
|
||||
const entries = [
|
||||
dated("gitea", "2025-08-01"),
|
||||
dated("astro-profile", "2025-08-01"),
|
||||
]
|
||||
|
||||
// Act: sort twice to prove the result is stable, not build-order dependent.
|
||||
const first = [...entries].sort(byDateDesc).map((entry) => entry.id)
|
||||
const second = [...entries.reverse()].sort(byDateDesc).map((entry) => entry.id)
|
||||
|
||||
// Assert
|
||||
expect(first).toEqual(["astro-profile", "gitea"])
|
||||
expect(second).toEqual(first)
|
||||
})
|
||||
|
||||
it("should leave single-entry and empty collections untouched without throwing", () => {
|
||||
expect([...[dated("only", "2026-11-03")]].sort(byDateDesc).map((e) => e.id)).toEqual([
|
||||
"only",
|
||||
])
|
||||
expect(([] as ReturnType<typeof dated>[]).sort(byDateDesc)).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,101 @@
|
||||
// src/lib/__tests__/search.test.ts
|
||||
import { describe, it, expect } from "vitest"
|
||||
import {
|
||||
createSearcher,
|
||||
partitionByCollection,
|
||||
runSearch,
|
||||
MIN_QUERY_LENGTH,
|
||||
} from "../search"
|
||||
import type { SearchEntry } from "@lib/types"
|
||||
|
||||
const ENTRIES: SearchEntry[] = [
|
||||
{
|
||||
id: "01-building-my-personal-website",
|
||||
slug: "01-building-my-personal-website",
|
||||
collection: "blog",
|
||||
title: "Building My Personal Website: From Idea to Deployment",
|
||||
summary: "A journey through creating my personal portfolio site.",
|
||||
tags: ["Tutorial", "Astro", "Portfolio", "Docker"],
|
||||
date: "2025-08-12T00:00:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "astro-profile",
|
||||
slug: "astro-profile",
|
||||
collection: "projects",
|
||||
title: "Astro Profile",
|
||||
summary: "An Astro-based profile template with built in markdown support.",
|
||||
tags: ["portfolio", "personal", "astro"],
|
||||
date: "2025-08-08T00:00:00.000Z",
|
||||
},
|
||||
]
|
||||
|
||||
describe("createSearcher / runSearch", () => {
|
||||
const searcher = createSearcher(ENTRIES)
|
||||
|
||||
it("should return no results when the query is shorter than MIN_QUERY_LENGTH", () => {
|
||||
expect(runSearch(searcher, "")).toEqual([])
|
||||
expect(runSearch(searcher, "a")).toEqual([])
|
||||
// Whitespace-only input is treated as empty.
|
||||
expect(runSearch(searcher, " ")).toEqual([])
|
||||
})
|
||||
|
||||
it("should match on title", () => {
|
||||
const results = runSearch(searcher, "website")
|
||||
expect(results.map((entry) => entry.slug)).toContain(
|
||||
"01-building-my-personal-website"
|
||||
)
|
||||
})
|
||||
|
||||
it("should match tags case-insensitively", () => {
|
||||
const results = runSearch(searcher, "ASTRO")
|
||||
expect(results.length).toBeGreaterThan(0)
|
||||
expect(results.map((entry) => entry.slug)).toContain("astro-profile")
|
||||
})
|
||||
|
||||
it("should tolerate a mistyped query (fuzzy match)", () => {
|
||||
const results = runSearch(searcher, "websit")
|
||||
expect(results.map((entry) => entry.slug)).toContain(
|
||||
"01-building-my-personal-website"
|
||||
)
|
||||
})
|
||||
|
||||
it("should return no results when nothing matches", () => {
|
||||
expect(runSearch(searcher, "zzzq")).toEqual([])
|
||||
})
|
||||
|
||||
it("should never return fewer results than an exact substring match would", () => {
|
||||
const query = "deployment"
|
||||
const contains = ENTRIES.filter((entry) => entry.title.includes(query))
|
||||
expect(runSearch(searcher, query).length).toBeGreaterThanOrEqual(
|
||||
contains.length
|
||||
)
|
||||
})
|
||||
|
||||
it("should handle an empty dataset without throwing", () => {
|
||||
const empty = createSearcher([])
|
||||
expect(runSearch(empty, "astro")).toEqual([])
|
||||
})
|
||||
|
||||
it("should not require MIN_QUERY_LENGTH to change the contract", () => {
|
||||
expect(MIN_QUERY_LENGTH).toBeGreaterThan(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("partitionByCollection", () => {
|
||||
it("should split results into posts and projects by collection", () => {
|
||||
const { posts, projects } = partitionByCollection(ENTRIES)
|
||||
expect(posts.map((entry) => entry.slug)).toEqual([
|
||||
"01-building-my-personal-website",
|
||||
])
|
||||
expect(projects.map((entry) => entry.slug)).toEqual(["astro-profile"])
|
||||
})
|
||||
|
||||
it("should return empty buckets for an empty result set", () => {
|
||||
expect(partitionByCollection([])).toEqual({ posts: [], projects: [] })
|
||||
})
|
||||
|
||||
it("should preserve every entry exactly once across both buckets", () => {
|
||||
const { posts, projects } = partitionByCollection(ENTRIES)
|
||||
expect(posts.length + projects.length).toBe(ENTRIES.length)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
// src/lib/__tests__/utils.test.ts
|
||||
import { describe, it, expect } from "vitest"
|
||||
import { formatDate, readingTime } from "@lib/utils"
|
||||
|
||||
describe("formatDate", () => {
|
||||
it("should render a frontmatter date exactly as authored when it is midnight UTC", () => {
|
||||
expect(formatDate(new Date("2025-08-12T00:00:00.000Z"))).toBe("Aug 12, 2025")
|
||||
})
|
||||
|
||||
it("should not shift the day when given an ISO string instead of a Date", () => {
|
||||
expect(formatDate("2026-11-03T00:00:00.000Z")).toBe("Nov 03, 2026")
|
||||
})
|
||||
|
||||
it("should stay stable for a date near the end of a month across timezones", () => {
|
||||
expect(formatDate(new Date("2026-11-30T00:00:00.000Z"))).toBe("Nov 30, 2026")
|
||||
})
|
||||
})
|
||||
|
||||
describe("readingTime", () => {
|
||||
it("should return a whole-number minute estimate for html content", () => {
|
||||
expect(readingTime("<p>one two three</p>")).toBe("1 min read")
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,43 @@
|
||||
// src/lib/content.ts
|
||||
import type { CollectionEntry } from "astro:content"
|
||||
import type { SearchEntry } from "@lib/types"
|
||||
|
||||
/**
|
||||
* Structural shape of anything the glob loader hands back for a dated
|
||||
* collection. Deliberately narrower than CollectionEntry<"blog"> so the
|
||||
* comparator can be unit tested without Astro's virtual module.
|
||||
*/
|
||||
interface DatedEntry {
|
||||
id: string
|
||||
data: { date: Date }
|
||||
}
|
||||
|
||||
/**
|
||||
* The glob loader returns entries in filename order, never by frontmatter
|
||||
* date, so every listing page must opt into date ordering explicitly.
|
||||
* Equal dates fall back to id to keep the order deterministic across builds
|
||||
* (two projects share 2025-08-01).
|
||||
*/
|
||||
export function byDateDesc(a: DatedEntry, b: DatedEntry): number {
|
||||
const diff = b.data.date.getTime() - a.data.date.getTime()
|
||||
return diff !== 0 ? diff : a.id.localeCompare(b.id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a blog or project content entry down to the slim, serializable shape
|
||||
* used by ArrowCard and the search index. Centralising this keeps every page
|
||||
* (home, blog, projects, search) emitting identical card props.
|
||||
*/
|
||||
export function toSearchEntry(
|
||||
entry: CollectionEntry<"blog"> | CollectionEntry<"projects">
|
||||
): SearchEntry {
|
||||
return {
|
||||
id: entry.id,
|
||||
slug: entry.id,
|
||||
collection: entry.collection as "blog" | "projects",
|
||||
title: entry.data.title,
|
||||
summary: entry.data.summary,
|
||||
tags: entry.data.tags,
|
||||
date: entry.data.date.toISOString(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// src/lib/search.ts
|
||||
import Fuse, { type IFuseOptions } from "fuse.js"
|
||||
import type { SearchEntry } from "@lib/types"
|
||||
|
||||
export type { SearchEntry }
|
||||
|
||||
/** Minimum characters before we bother running a query. */
|
||||
export const MIN_QUERY_LENGTH = 2
|
||||
|
||||
const FUSE_OPTIONS: IFuseOptions<SearchEntry> = {
|
||||
keys: [
|
||||
{ name: "title", weight: 0.4 },
|
||||
{ name: "tags", weight: 0.35 },
|
||||
{ name: "summary", weight: 0.25 },
|
||||
],
|
||||
threshold: 0.4,
|
||||
ignoreLocation: true,
|
||||
minMatchCharLength: MIN_QUERY_LENGTH,
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a reusable fuzzy searcher over a set of entries.
|
||||
*
|
||||
* The index is created once per island hydration, so typing does not rebuild
|
||||
* it on every keystroke.
|
||||
*/
|
||||
export function createSearcher(entries: SearchEntry[]): Fuse<SearchEntry> {
|
||||
return new Fuse(entries, FUSE_OPTIONS)
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a fuzzy query. Queries shorter than `MIN_QUERY_LENGTH` yield no results,
|
||||
* which lets the UI distinguish "not searched yet" from "searched, found none".
|
||||
*/
|
||||
export function runSearch(
|
||||
searcher: Fuse<SearchEntry>,
|
||||
rawQuery: string
|
||||
): SearchEntry[] {
|
||||
const query = rawQuery.trim()
|
||||
if (query.length < MIN_QUERY_LENGTH) return []
|
||||
return searcher.search(query).map((result) => result.item)
|
||||
}
|
||||
|
||||
/**
|
||||
* Partition a flat result set back into per-collection buckets for rendering.
|
||||
*/
|
||||
export function partitionByCollection(results: SearchEntry[]): {
|
||||
posts: SearchEntry[]
|
||||
projects: SearchEntry[]
|
||||
} {
|
||||
return {
|
||||
posts: results.filter((entry) => entry.collection === "blog"),
|
||||
projects: results.filter((entry) => entry.collection === "projects"),
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,30 @@ export interface Project {
|
||||
repoUrl: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The slim, client-serializable shape of a searchable document.
|
||||
*
|
||||
* Markdown `body` is deliberately excluded: serializing every post's full
|
||||
* content into the island's `props` measured 21,873 chars (43.5 KB page) and
|
||||
* was never matched against, so it was pure payload tax.
|
||||
*/
|
||||
export interface SearchEntry {
|
||||
id: string;
|
||||
slug: string;
|
||||
collection: "blog" | "projects";
|
||||
title: string;
|
||||
summary: string;
|
||||
tags: string[];
|
||||
date: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shape accepted by ArrowCard. A union so the cards on the blog/projects
|
||||
* listing pages (flat BlogPost/Project) and search results (SearchEntry,
|
||||
* which carries `collection` + `slug`) both type-check.
|
||||
*/
|
||||
export type CardEntry = BlogPost | Project | SearchEntry
|
||||
|
||||
export interface WorkExperience {
|
||||
id: string;
|
||||
company: string;
|
||||
|
||||
+5
-1
@@ -10,7 +10,11 @@ export function formatDate(date: Date | string) {
|
||||
return Intl.DateTimeFormat("en-US", {
|
||||
month: "short",
|
||||
day: "2-digit",
|
||||
year: "numeric"
|
||||
year: "numeric",
|
||||
// Frontmatter dates such as `date: 2025-08-12` parse to midnight UTC. Without
|
||||
// pinning the timezone, formatting in a negative-offset locale (EST) shifted
|
||||
// every authored date one day earlier on screen.
|
||||
timeZone: "UTC",
|
||||
}).format(date)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,18 @@ export const prerender = true
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const entries = await getCollection("blog", ({ data }) => !data.draft)
|
||||
return entries.map((entry) => ({
|
||||
// The article layouts expect the flat BlogPost shape (title/summary/date at the
|
||||
// top level). Astro's collection entries nest frontmatter under `data`, so
|
||||
// spreading the entry alone left every article heading blank and made
|
||||
// formatDate(undefined) fall back to today's date.
|
||||
const flat = entries.map((entry) => ({
|
||||
...entry,
|
||||
...entry.data,
|
||||
content: entry.rendered?.html ?? "",
|
||||
}))
|
||||
return entries.map((entry, i) => ({
|
||||
params: { slug: entry.id },
|
||||
props: { entry: { ...entry, content: entry.rendered?.html }, allEntries: entries },
|
||||
props: { entry: flat[i], allEntries: flat },
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,12 @@ import TopLayout from "@layouts/TopLayout.astro"
|
||||
import BottomLayout from "@layouts/BottomLayout.astro"
|
||||
import Blog from "@components/Blog"
|
||||
import { BLOG } from "@consts"
|
||||
import { byDateDesc } from "@lib/content"
|
||||
|
||||
const entries = await getCollection("blog", ({ data }) => !data.draft)
|
||||
const posts = entries.map((entry) => ({
|
||||
const posts = entries
|
||||
.sort(byDateDesc)
|
||||
.map((entry) => ({
|
||||
id: entry.id,
|
||||
slug: entry.id,
|
||||
title: entry.data.title,
|
||||
@@ -18,7 +21,7 @@ const posts = entries.map((entry) => ({
|
||||
content: entry.body ?? "",
|
||||
template: entry.data.template,
|
||||
featured: entry.data.featured,
|
||||
}))
|
||||
}))
|
||||
const tags = Array.from(new Set(posts.flatMap((p) => p.tags)))
|
||||
---
|
||||
|
||||
|
||||
+13
-17
@@ -4,26 +4,21 @@ import PageLayout from "@layouts/PageLayout.astro"
|
||||
import ArrowCard from "@components/ArrowCard"
|
||||
import StackCard from "@components/StackCard.astro"
|
||||
import { SITE, SOCIALS } from "@consts"
|
||||
import { byDateDesc, toSearchEntry } from "@lib/content"
|
||||
import TwinklingStars from "@components/TwinklingStars.astro"
|
||||
import MeteorShower from "@components/MeteorShower.astro"
|
||||
|
||||
const allBlogEntries = await getCollection("blog", ({ data }) => !data.draft)
|
||||
const posts = allBlogEntries.slice(0, 3).map((entry) => ({
|
||||
$id: entry.id,
|
||||
title: entry.data.title,
|
||||
summary: entry.data.summary,
|
||||
date: entry.data.date,
|
||||
tags: entry.data.tags,
|
||||
}))
|
||||
const posts = allBlogEntries
|
||||
.sort(byDateDesc)
|
||||
.slice(0, 3)
|
||||
.map(toSearchEntry)
|
||||
|
||||
const allProjectEntries = await getCollection("projects", ({ data }) => !data.draft)
|
||||
const projects = allProjectEntries.slice(0, 3).map((entry) => ({
|
||||
$id: entry.id,
|
||||
title: entry.data.title,
|
||||
summary: entry.data.summary,
|
||||
date: entry.data.date,
|
||||
tags: entry.data.tags,
|
||||
}))
|
||||
const projects = allProjectEntries
|
||||
.sort(byDateDesc)
|
||||
.slice(0, 3)
|
||||
.map(toSearchEntry)
|
||||
|
||||
const stack = [
|
||||
{
|
||||
@@ -98,10 +93,10 @@ const stack = [
|
||||
Passionate about spaghetti, noodles and all things tech.
|
||||
</p>
|
||||
<p class='animated text-sm md:text-base lg:text-lg opacity-75 mt-2'>
|
||||
Running 2 Unraid servers with Docker container ecosystem
|
||||
Two home servers: one stores everything, one does the thinking
|
||||
</p>
|
||||
<p class='animated text-sm md:text-base lg:text-lg opacity-75 mt-1'>
|
||||
Supporting PostgreSQL, MariaDB, MySQL, MongoDB, Redis, and Minio
|
||||
258 TB of storage, 81 services, and AI that runs in my own house
|
||||
</p>
|
||||
<div id="ctaButtons" class='animated flex flex-wrap gap-4 justify-center mt-5'>
|
||||
<a href='/blog' class='py-2 px-4 rounded truncate text-xs md:text-sm lg:text-base bg-spaghetti-red dark:bg-spaghetti-red dark:text-spaghetti-brown hover:opacity-75 blend'>
|
||||
@@ -126,7 +121,8 @@ const stack = [
|
||||
<p>With 10+ years of experience building high-performing engineering teams and driving innovation in dynamic environments, I combine deep technical expertise with exceptional emotional intelligence and a human-centered leadership approach.</p>
|
||||
<p>I specialize in IT Service Management (ITSM), IT Operations Management (ITOM), and IT Asset Management (ITAM), positioning myself as a trusted advisor to enterprise clients.</p>
|
||||
<p>My technical background includes extensive experience with Docker, Kubernetes, and cloud platforms to deliver scalable, secure, and compliant solutions for complex projects.</p>
|
||||
<p>Currently running 2 Unraid servers with powerful hardware configurations (128GB RAM, 2 x E5 Xeon CPU, 200TB raw storage on NetApp arrays) and a comprehensive Docker container ecosystem supporting PostgreSQL, MariaDB, MySQL, MongoDB, Redis, and Minio.</p>
|
||||
<p>Currently I run two home servers built for opposite jobs. <strong>MarvinBlade</strong> holds about 258 TB across thirty hard drives, with extra protection so the files survive drives failing. <strong>SpaghetAI</strong> has almost no storage at all but a great deal of memory and two graphics cards, so that AI tools can answer questions about my own documents without those documents leaving the house. Eighty-one programs run across the two, covering media, photos, files, finances, and automation, with one sign-in protecting the things that matter.</p>
|
||||
<p>How and why, in plain language: <a href="/blog/04-marvinblade-and-spaghetai/">Running AI From My Own Computers</a>.</p>
|
||||
<p>Just like the perfect bowl of spaghetti - structured, well-organized, and satisfying to use - I'm passionate about creating technology solutions that are both functional and elegant.</p>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -10,9 +10,16 @@ export const prerender = true
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const entries = await getCollection("projects", ({ data }) => !data.draft)
|
||||
return entries.map((entry) => ({
|
||||
// Flatten frontmatter to the shape ArticleTopLayout/ArticleBottomLayout expect;
|
||||
// see the note in src/pages/blog/[...slug].astro.
|
||||
const flat = entries.map((entry) => ({
|
||||
...entry,
|
||||
...entry.data,
|
||||
content: entry.rendered?.html ?? "",
|
||||
}))
|
||||
return entries.map((entry, i) => ({
|
||||
params: { slug: entry.id },
|
||||
props: { entry: { ...entry, content: entry.rendered?.html }, allEntries: entries },
|
||||
props: { entry: flat[i], allEntries: flat },
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,12 @@ import TopLayout from "@layouts/TopLayout.astro"
|
||||
import BottomLayout from "@layouts/BottomLayout.astro"
|
||||
import Projects from "@components/Projects"
|
||||
import { PROJECTS } from "@consts"
|
||||
import { byDateDesc } from "@lib/content"
|
||||
|
||||
const entries = await getCollection("projects", ({ data }) => !data.draft)
|
||||
const posts = entries.map((entry) => ({
|
||||
const posts = entries
|
||||
.sort(byDateDesc)
|
||||
.map((entry) => ({
|
||||
id: entry.id,
|
||||
slug: entry.id,
|
||||
title: entry.data.title,
|
||||
@@ -18,7 +21,7 @@ const posts = entries.map((entry) => ({
|
||||
content: entry.body ?? "",
|
||||
demoUrl: entry.data.demoUrl,
|
||||
repoUrl: entry.data.repoUrl,
|
||||
}))
|
||||
}))
|
||||
const tags = Array.from(new Set(posts.flatMap((p) => p.tags)))
|
||||
---
|
||||
|
||||
|
||||
@@ -5,41 +5,41 @@ import TopLayout from "@layouts/TopLayout.astro"
|
||||
import BottomLayout from "@layouts/BottomLayout.astro"
|
||||
import Search from "@components/Search"
|
||||
import { SEARCH } from "@consts"
|
||||
import type { SearchEntry } from "@lib/search"
|
||||
|
||||
// Fetch blog posts
|
||||
// Blog posts -> slim searchable entries.
|
||||
// `body` is intentionally NOT serialized to the client; see src/lib/search.ts.
|
||||
const blogEntries = await getCollection("blog", ({ data }) => !data.draft)
|
||||
const posts = blogEntries.map((entry) => ({
|
||||
const posts: SearchEntry[] = blogEntries.map((entry) => ({
|
||||
id: entry.id,
|
||||
slug: entry.id,
|
||||
collection: "blog",
|
||||
title: entry.data.title,
|
||||
summary: entry.data.summary,
|
||||
date: entry.data.date.toISOString(),
|
||||
tags: entry.data.tags,
|
||||
draft: entry.data.draft,
|
||||
content: entry.body ?? "",
|
||||
template: entry.data.template,
|
||||
featured: entry.data.featured,
|
||||
}))
|
||||
|
||||
// Fetch projects
|
||||
// Projects -> slim searchable entries.
|
||||
const projectEntries = await getCollection("projects", ({ data }) => !data.draft)
|
||||
const projects = projectEntries.map((entry) => ({
|
||||
const projects: SearchEntry[] = projectEntries.map((entry) => ({
|
||||
id: entry.id,
|
||||
slug: entry.id,
|
||||
collection: "projects",
|
||||
title: entry.data.title,
|
||||
summary: entry.data.summary,
|
||||
date: entry.data.date.toISOString(),
|
||||
tags: entry.data.tags,
|
||||
draft: entry.data.draft,
|
||||
content: entry.body ?? "",
|
||||
demoUrl: entry.data.demoUrl || "",
|
||||
repoUrl: entry.data.repoUrl || "",
|
||||
}))
|
||||
|
||||
// Handle URL search parameters
|
||||
const url = new URL(typeof window !== 'undefined' ? window.location.href : 'http://localhost')
|
||||
const searchParam = url.searchParams.get('search') || ''
|
||||
const initialQuery = searchParam
|
||||
const entries: SearchEntry[] = [...posts, ...projects]
|
||||
|
||||
// Read the `?search=` param from the incoming SSR request.
|
||||
// NOTE: this frontmatter runs on the server, so `window` is never available
|
||||
// here. The previous `typeof window !== 'undefined' ? window.location.href : ...`
|
||||
// guard always fell through to a query-less localhost URL, so deep links,
|
||||
// refreshes and back/forward silently lost the user's query.
|
||||
const initialQuery = Astro.url.searchParams.get("search") ?? ""
|
||||
---
|
||||
|
||||
<PageLayout title={SEARCH.TITLE} description={SEARCH.DESCRIPTION}>
|
||||
@@ -50,7 +50,7 @@ const initialQuery = searchParam
|
||||
</TopLayout>
|
||||
<BottomLayout>
|
||||
<div class="animate" id="search-container">
|
||||
<Search client:load query={initialQuery} posts={posts} projects={projects} />
|
||||
<Search client:load query={initialQuery} entries={entries} />
|
||||
</div>
|
||||
</BottomLayout>
|
||||
</PageLayout>
|
||||
+44
-15
@@ -1,6 +1,35 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@import "tailwindcss";
|
||||
|
||||
/* v4 replacement for v3's `darkMode: "class"`. Required so public/js/theme.js
|
||||
toggling `.dark` on <html> actually drives the `dark:` utilities. */
|
||||
@custom-variant dark (&:where(.dark, .dark *));
|
||||
|
||||
@plugin "@tailwindcss/typography";
|
||||
|
||||
@theme {
|
||||
--color-spaghetti-yellow: #FDE68A;
|
||||
--color-spaghetti-red: #FECACA;
|
||||
--color-spaghetti-cream: #FEF3C7;
|
||||
--color-spaghetti-brown: #78350F;
|
||||
--color-spaghetti-dark-cream: #F5E6D3;
|
||||
--color-spaghetti-dark-red: #FCA5A5;
|
||||
--color-spaghetti-dark-yellow: #FCD34D;
|
||||
|
||||
--animate-twinkle: twinkle 2s ease-in-out forwards;
|
||||
--animate-meteor: meteor 3s ease-in-out forwards;
|
||||
|
||||
@keyframes twinkle {
|
||||
0% { opacity: 0; transform: rotate(0deg); }
|
||||
50% { opacity: 1; transform: rotate(180deg); }
|
||||
100% { opacity: 0; transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
@keyframes meteor {
|
||||
0% { opacity: 0; transform: translateY(200%); }
|
||||
50% { opacity: 1; }
|
||||
100% { opacity: 0; transform: translateY(0); }
|
||||
}
|
||||
}
|
||||
|
||||
:root{
|
||||
--copy-btn-margin:10px;
|
||||
@@ -78,26 +107,26 @@ body {
|
||||
color: var(--spaghetti-red) !important;
|
||||
}
|
||||
|
||||
.prose h1,
|
||||
.prose h2,
|
||||
.prose h3,
|
||||
.prose h4,
|
||||
.prose h5,
|
||||
.prose h6 {
|
||||
color: #ffffff !important;
|
||||
.dark .prose h1,
|
||||
.dark .prose h2,
|
||||
.dark .prose h3,
|
||||
.dark .prose h4,
|
||||
.dark .prose h5,
|
||||
.dark .prose h6 {
|
||||
color: var(--spaghetti-dark-cream) !important;
|
||||
}
|
||||
|
||||
.prose code {
|
||||
color: #ffffff !important;
|
||||
.dark .prose code {
|
||||
color: var(--spaghetti-dark-cream) !important;
|
||||
}
|
||||
|
||||
.prose blockquote {
|
||||
border-left-color: var(--spaghetti-yellow) !important;
|
||||
}
|
||||
|
||||
.prose th,
|
||||
.prose td {
|
||||
color: #ffffff !important;
|
||||
.dark .prose th,
|
||||
.dark .prose td {
|
||||
color: var(--spaghetti-dark-cream) !important;
|
||||
}
|
||||
|
||||
.page-heading {
|
||||
|
||||
+2
-6
@@ -1,13 +1,10 @@
|
||||
import defaultTheme from "tailwindcss/defaultTheme"
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
darkMode: ["class"],
|
||||
darkMode: "class",
|
||||
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
"sans": ["Atkinson", ...defaultTheme.fontFamily.sans],
|
||||
sans: ["Atkinson", "system-ui", "sans-serif"],
|
||||
},
|
||||
typography: {
|
||||
DEFAULT: {
|
||||
@@ -103,6 +100,5 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: [require("@tailwindcss/typography")],
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// vitest.config.ts
|
||||
import { defineConfig } from "vitest/config"
|
||||
import { fileURLToPath } from "node:url"
|
||||
|
||||
// Mirrors the tsconfig path aliases so modules under test can import via @lib/...
|
||||
const src = fileURLToPath(new URL("./src", import.meta.url))
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
"@lib": `${src}/lib`,
|
||||
"@components": `${src}/components`,
|
||||
"@layouts": `${src}/layouts`,
|
||||
"@pages": `${src}/pages`,
|
||||
"@styles": `${src}/styles`,
|
||||
"@consts": `${src}/consts.ts`,
|
||||
"@types": `${src}/types.ts`,
|
||||
},
|
||||
},
|
||||
test: {
|
||||
environment: "node",
|
||||
include: ["src/**/__tests__/**/*.test.ts", "src/**/*.test.ts"],
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user