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:
spaghet committed 2026-11-04 12:31:58 -05:00
1 parent ac545c4668
commit 3fef5d378e
26 files changed
+1822 -3548

No files matched your search

+99 -42
View File
@@ -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
// Client-side search through provided data
// 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())
}
}
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)
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()}'`}