Files
xevion.dev/web/src/routes/admin/projects/[id]/+page.server.ts
Xevion 935c5e6475 refactor: migrate icon rendering to SVG sprite pattern
Replace per-icon inline SVG rendering with a centralized sprite system. Icons are now collected once per page and rendered as <symbol> elements, referenced via <use> tags. Eliminates redundant icon fetching, reduces HTML size, and simplifies icon management across components.
2026-01-15 01:59:02 -06:00

32 lines
858 B
TypeScript

import type { PageServerLoad } from "./$types";
import { apiFetch } from "$lib/api.server";
import { collectTagIcons } from "$lib/server/tag-icons";
import type {
AdminProject,
AdminTagWithCount,
AdminTag,
} from "$lib/admin-types";
export const load: PageServerLoad = async ({ params, fetch }) => {
const { id } = params;
// Fetch project and tags in parallel
const [project, availableTags] = await Promise.all([
apiFetch<AdminProject>(`/api/projects/${id}`, { fetch }).catch(() => null),
apiFetch<AdminTagWithCount[]>("/api/tags", { fetch }),
]);
// Collect icons for sprite (from available tags + project tags)
const allTags: AdminTag[] = [...availableTags];
if (project) {
allTags.push(...project.tags);
}
const icons = await collectTagIcons(allTags);
return {
project,
availableTags,
icons,
};
};