From 8bc54c76ae6f27b92afc396d55444ca12c46207f Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 13 May 2024 00:16:22 -0700 Subject: [PATCH] feat: hide navbar on blog posts to reduce clutter --- src/lib/components/Navbar/Navbar.svelte | 23 ++++++++++++++++++----- src/lib/components/Toc/TocHeader.svelte | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/lib/components/Navbar/Navbar.svelte b/src/lib/components/Navbar/Navbar.svelte index b415f63..faba6cf 100644 --- a/src/lib/components/Navbar/Navbar.svelte +++ b/src/lib/components/Navbar/Navbar.svelte @@ -9,12 +9,21 @@ import Button from '../ui/button/button.svelte' import { Moon, Sun } from 'svelte-radix' - let current: 'blog' | 'about' | 'home' | 'portfolio' | string + let current: 'blogpost' | 'blog' | 'about' | 'home' | 'portfolio' | string const updateCurrent = () => { const path = window.location.pathname - if (path === '/') { - current = 'home' + // if (path === '/') { + // current = 'home' + // } else { + // const segments = path.split('/') + // current = segments[1] || 'home' + // } + + if (path === '/blog') { + current = 'blog' + } else if (path.startsWith('/blog')) { + current = 'blogpost' } else { const segments = path.split('/') current = segments[1] || 'home' @@ -24,10 +33,14 @@ onMount(() => navigating.subscribe(updateCurrent)) -