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 {
|
||||
return (
|
||||
<Image
|
||||
src={getImageSrc(value.src)}
|
||||
src={getImageSrc(value.src) || "/not-found.png"}
|
||||
width={value.width}
|
||||
height={value.height}
|
||||
format="webp"
|
||||
|
@ -1,9 +1,11 @@
|
||||
---
|
||||
import { getCurrentYear } from "@/utils/date";
|
||||
import ThemeSwitcher from "./ThemeSwitcher.astro";
|
||||
---
|
||||
|
||||
<footer>
|
||||
<footer class="flex justify-between">
|
||||
<p class="text-lg font-semibold">
|
||||
© {getCurrentYear()} Example Website. All rights reserved.
|
||||
</p>
|
||||
<ThemeSwitcher/>
|
||||
</footer>
|
@ -8,15 +8,15 @@ const { post } = Astro.props;
|
||||
href={`/posts/${post.id}/`}
|
||||
>
|
||||
<article class="flex px-5 py-3 gap-8">
|
||||
<Image
|
||||
src={post.thumbnail.url}
|
||||
height="150"
|
||||
aspectRatio="1"
|
||||
<Image
|
||||
src={post.thumbnail.url || "/not-found"}
|
||||
height={150}
|
||||
aspectRatio={1}
|
||||
format="webp"
|
||||
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">
|
||||
<h3 class="">{post.title}</h3>
|
||||
{post.publishedDate && (
|
||||
@ -24,8 +24,8 @@ const { post } = Astro.props;
|
||||
{new Date(post.publishedDate).toLocaleDateString("de-DE")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{post.summary && <p>
|
||||
</div>
|
||||
{post.summary && <p class="max-w-prose">
|
||||
{post.summary}
|
||||
</p>}
|
||||
</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