feat(projects): load preview image in component instead of doing it in the store

This commit is contained in:
2025-11-23 13:28:59 +01:00
parent d1a239fc32
commit 73fbd462be
3 changed files with 50 additions and 93 deletions

View File

@@ -62,15 +62,17 @@ export const useProjectsStore = defineStore("projects", {
projects: [] as {
description: string;
thumbnail: string;
preview: HTMLImageElement;
preview: string;
url: string | null;
body: MarkdownBody;
}[],
currentProject: 0,
loading: true,
}),
actions: {
async loadProjects() {
this.loading = true;
const { data: projects } = await useAsyncData("projects", () =>
queryCollection("projects").order("order", "ASC").all(),
);
@@ -84,11 +86,13 @@ export const useProjectsStore = defineStore("projects", {
this.projects.push({
description: project.description,
thumbnail: `/images/projects/thumbnails/${id}.webp`,
preview: createImage(`/images/projects/previews/${id}.webp`),
preview: `/images/projects/previews/${id}.webp`,
url: project.url,
body: simplifyMarkdownAST(project.body),
});
}
this.loading = false;
},
visitProject() {