mirror of
https://github.com/Xevion/xevion.dev.git
synced 2026-01-31 14:26:37 -06:00
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.
This commit is contained in:
@@ -1,22 +1,31 @@
|
||||
import type { PageServerLoad } from "./$types";
|
||||
import { apiFetch } from "$lib/api.server";
|
||||
import { addIconsToTags } from "$lib/server/tag-icons";
|
||||
import type { AdminProject, AdminTagWithCount } from "$lib/admin-types";
|
||||
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, tagsWithCounts] = await Promise.all([
|
||||
const [project, availableTags] = await Promise.all([
|
||||
apiFetch<AdminProject>(`/api/projects/${id}`, { fetch }).catch(() => null),
|
||||
apiFetch<AdminTagWithCount[]>("/api/tags", { fetch }),
|
||||
]);
|
||||
|
||||
// Add icons to tags
|
||||
const availableTags = await addIconsToTags(tagsWithCounts);
|
||||
// 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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user