fix links, start working on theme toggle

This commit is contained in:
Silas 2024-06-10 22:10:20 -04:00
parent 3320683d10
commit 006d5390c5
Failed to generate hash of commit
3 changed files with 28 additions and 2 deletions

View File

@ -0,0 +1,26 @@
<script lang="ts">
// Reactive variable to store the current theme
let theme = 'forest'; // default theme
// On component mount, check for saved theme in local storage
import { onMount } from 'svelte';
onMount(() => {
theme = localStorage.getItem('theme') || 'forest';
updateTheme();
});
// Function to toggle theme
function toggleTheme() {
theme = theme === 'forest' ? 'light' : 'forest';
localStorage.setItem('theme', theme);
updateTheme();
}
// Function to update the theme on the body element
function updateTheme() {
document.body.setAttribute('data-theme', theme);
}
</script>
<button on:click={toggleTheme}>Toggle Theme</button>

View File

@ -62,7 +62,7 @@
{#each posts as post}
<li class="py-4">
<h3 class="pb-1">
<a class="link-primary" href={post.path}>
<a class="link-primary" href={`/poetry/${post.filename}`}>
{post.meta.title}
</a>
</h3>

View File

@ -62,7 +62,7 @@
{#each posts as post}
<li class="py-4">
<h3 class="pb-1">
<a class="link-primary" href={post.path}>
<a class="link-primary" href={`/thoughts/${post.filename}`}>
{post.meta.title}
</a>
</h3>