mirror of
https://github.com/Xevion/xevion.dev.git
synced 2026-01-31 06:26:44 -06:00
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.
32 lines
858 B
TypeScript
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,
|
|
};
|
|
};
|