diff --git a/src/components/HeroCard.astro b/src/components/HeroCard.astro index 7fd7a99..a763a6d 100644 --- a/src/components/HeroCard.astro +++ b/src/components/HeroCard.astro @@ -3,13 +3,14 @@ import markdownToText from "@helpers/markdownToText"; import { Card } from "./card"; import { useTranslatedPath, useTranslations } from "@i18n/utils"; import Image from "@components/Image.astro"; +import type { ImageMetadata } from "astro"; interface Props { post: { data: { title: string; icon?: string; - headerImg?: string; + cover?: ImageMetadata; }; collection: string; slug: string; @@ -18,7 +19,7 @@ interface Props { } const { - data: { title, headerImg, icon }, + data: { title, cover, icon }, collection, body, slug, @@ -27,15 +28,11 @@ const { const translatePath = useTranslatedPath(Astro.url); const t = useTranslations(Astro.url); -const imagePath = `../content/${collection}/${slug.split("/")[0]}/${headerImg}`; - -const image = headerImg && (await import(imagePath)).default; - const link = translatePath(`/${collection}/${slug.split("/")[0]}`); --- @@ -48,10 +45,10 @@ const link = translatePath(`/${collection}/${slug.split("/")[0]}`); { - image?.format && ( + cover && ( {"cover diff --git a/src/components/ThemeToggle.svelte b/src/components/ThemeToggle.svelte index b9eebfe..7ef2942 100644 --- a/src/components/ThemeToggle.svelte +++ b/src/components/ThemeToggle.svelte @@ -2,11 +2,7 @@ import { onMount } from "svelte"; import { writable } from "svelte/store"; - let theme = writable("light"); - - onMount(() => { - theme.set(localStorage.getItem("theme") || "light"); - }); + let theme = writable(""); $: if ($theme && "document" in globalThis) { document.documentElement.classList.remove("light", "dark"); @@ -15,9 +11,12 @@ } function toggleTheme() { - console.log($theme); theme.update((t) => (t === "light" ? "dark" : "light")); } + + onMount(() => { + theme.set(localStorage.getItem("theme") || "dark"); + });