Mae's website :3 maemoon.me
personal website svelte sveltekit
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

asterisks

+87 -11
+71
src/lib/breadcrumb.svelte
··· 1 + <script> 2 + let { path } = $props(); 3 + 4 + let splitPath = $derived.by(() => { 5 + let fullPath = "home" + path; 6 + return fullPath.split("/").filter(Boolean); 7 + }); 8 + 9 + // Define which paths should be linked vs just displayed 10 + const nonLinkablePaths = ['post']; 11 + 12 + // Generate the href for each breadcrumb segment, returning null for non-linkable paths 13 + function getHref(segment, index) { 14 + // Home always links to root 15 + if (segment.toLowerCase() === 'home') { 16 + return '/'; 17 + } 18 + 19 + // Don't generate links for segments in nonLinkablePaths 20 + if (nonLinkablePaths.includes(segment.toLowerCase())) { 21 + return null; 22 + } 23 + 24 + // For blog section, link directly to /blog 25 + if (segment.toLowerCase() === 'blog') { 26 + return '/blog'; 27 + } 28 + 29 + // For other segments (like the actual post slug) 30 + return '/' + splitPath.slice(1, index + 1).join('/'); 31 + } 32 + </script> 33 + 34 + <div> 35 + {#each splitPath as segment, index} 36 + {#if index > 0} 37 + <span>/</span> 38 + {/if} 39 + {#if getHref(segment, index) !== null} 40 + <a href={getHref(segment, index)}>{segment}</a> 41 + {:else} 42 + <span class="non-link">{segment}</span> 43 + {/if} 44 + {/each} 45 + </div> 46 + 47 + <style> 48 + div { 49 + display: flex; 50 + gap: 0.5rem; 51 + align-items: center; 52 + } 53 + 54 + a { 55 + text-decoration: none; 56 + color: inherit; 57 + font-size: 1.2em; 58 + } 59 + 60 + span { 61 + font-size: 1.2em; 62 + } 63 + 64 + a:hover { 65 + text-decoration: underline; 66 + } 67 + 68 + .non-link { 69 + color: var(--color-fg-4); /* Optional: style non-linkable segments differently */ 70 + } 71 + </style>
+16 -11
src/routes/+layout.svelte
··· 1 1 <script> 2 + import Breadcrumb from '../lib/breadcrumb.svelte'; 2 3 import '$lib/global.css'; 3 4 import { blur } from 'svelte/transition'; 4 5 ··· 15 16 <meta name="description" content="Mae Moon's personal website and blog"> 16 17 </svelte:head> 17 18 18 - {#key data.currentRoute} 19 - <div id="page"> 20 - <aside> 21 - <a href="/">home</a> 22 - <a href="/blog">blog</a> 23 - </aside> 24 - <main in:blur={{ duration: 200, delay: 200 }} out:blur={{ duration: 200 }}> 25 - {@render children?.()} 26 - </main> 27 - </div> 28 - {/key} 19 + <div id="page"> 20 + <aside> 21 + <a href="/" class:active={data.currentRoute == "/"}>home</a> 22 + <a href="/blog" class:active={data.currentRoute == "/blog"}>blog</a> 23 + </aside> 24 + {#key data.currentRoute} 25 + <main> 26 + {@render children?.()} 27 + </main> 28 + {/key} 29 + </div> 29 30 30 31 <style> 31 32 #page { ··· 43 44 main { 44 45 padding: 2em; 45 46 flex-basis: 50%; 47 + } 48 + 49 + .active::before { 50 + content: "* "; 46 51 } 47 52 </style>