generated from autonomic-cooperative/astro-payload-template
Compare commits
5 Commits
e99eb97462
...
0a2dde8009
Author | SHA1 | Date | |
---|---|---|---|
0a2dde8009 | |||
523b7c9fd7 | |||
6d213b7644 | |||
e20afa3313 | |||
aa7a5acf94 |
BIN
astro/public/not-found.png
Normal file
BIN
astro/public/not-found.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
@ -12,7 +12,7 @@ const contentArray = getContentArray(content);
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<Image
|
<Image
|
||||||
src={getImageSrc(value.src)}
|
src={getImageSrc(value.src) || "/not-found.png"}
|
||||||
width={value.width}
|
width={value.width}
|
||||||
height={value.height}
|
height={value.height}
|
||||||
format="webp"
|
format="webp"
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
---
|
---
|
||||||
import { getCurrentYear } from "@/utils/date";
|
import { getCurrentYear } from "@/utils/date";
|
||||||
|
import ThemeSwitcher from "./ThemeSwitcher.astro";
|
||||||
---
|
---
|
||||||
|
|
||||||
<footer>
|
<footer class="flex justify-between">
|
||||||
<p class="text-lg font-semibold">
|
<p class="text-lg font-semibold">
|
||||||
© {getCurrentYear()} Example Website. All rights reserved.
|
© {getCurrentYear()} Example Website. All rights reserved.
|
||||||
</p>
|
</p>
|
||||||
|
<ThemeSwitcher/>
|
||||||
</footer>
|
</footer>
|
@ -8,15 +8,15 @@ const { post } = Astro.props;
|
|||||||
href={`/posts/${post.id}/`}
|
href={`/posts/${post.id}/`}
|
||||||
>
|
>
|
||||||
<article class="flex px-5 py-3 gap-8">
|
<article class="flex px-5 py-3 gap-8">
|
||||||
<Image
|
<Image
|
||||||
src={post.thumbnail.url}
|
src={post.thumbnail.url || "/not-found"}
|
||||||
height="150"
|
height={150}
|
||||||
aspectRatio="1"
|
aspectRatio={1}
|
||||||
format="webp"
|
format="webp"
|
||||||
alt={post.thumbnail.alt}
|
alt={post.thumbnail.alt}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4 w-full">
|
||||||
<div class="flex justify-between w-full">
|
<div class="flex justify-between w-full">
|
||||||
<h3 class="">{post.title}</h3>
|
<h3 class="">{post.title}</h3>
|
||||||
{post.publishedDate && (
|
{post.publishedDate && (
|
||||||
@ -24,8 +24,8 @@ const { post } = Astro.props;
|
|||||||
{new Date(post.publishedDate).toLocaleDateString("de-DE")}
|
{new Date(post.publishedDate).toLocaleDateString("de-DE")}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{post.summary && <p>
|
{post.summary && <p class="max-w-prose">
|
||||||
{post.summary}
|
{post.summary}
|
||||||
</p>}
|
</p>}
|
||||||
</div>
|
</div>
|
||||||
|
12
astro/src/components/ThemeSwitcher.astro
Normal file
12
astro/src/components/ThemeSwitcher.astro
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
|
<select id="theme-selector">
|
||||||
|
<option value="autonomic">Autonomic</option>
|
||||||
|
<option value="light">Light</option>
|
||||||
|
<option value="dark">Dark</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { handleThemeChange, switchTheme, initializeThemeSelector } from "@/utils/theme"
|
||||||
|
initializeThemeSelector()
|
||||||
|
</script>
|
21
astro/src/utils/theme.ts
Normal file
21
astro/src/utils/theme.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export function switchTheme(themeClass: string): void {
|
||||||
|
const bodyElement = document.body;
|
||||||
|
const classesToRemove = ['light', 'dark', 'autonomic'];
|
||||||
|
|
||||||
|
bodyElement.classList.remove(...classesToRemove);
|
||||||
|
bodyElement.classList.add(themeClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleThemeChange(event: Event): void {
|
||||||
|
const selectElement = event.target as HTMLSelectElement;
|
||||||
|
const selectedTheme = selectElement.value;
|
||||||
|
|
||||||
|
switchTheme(selectedTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initializeThemeSelector(): void {
|
||||||
|
const themeSelector = document.getElementById('theme-selector');
|
||||||
|
if (themeSelector) {
|
||||||
|
themeSelector.addEventListener('change', handleThemeChange);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user