From 559d2339c97917d67c8004697465700653800e0d Mon Sep 17 00:00:00 2001 From: Pigges Date: Wed, 10 Jan 2024 22:57:10 +0100 Subject: [PATCH] update --- src/layouts/Collections.astro | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/layouts/Collections.astro b/src/layouts/Collections.astro index 730dac1..6236489 100644 --- a/src/layouts/Collections.astro +++ b/src/layouts/Collections.astro @@ -8,14 +8,22 @@ import TableOfContents from '../components/TableOfContents.astro'; import '../styles/markdown.css'; const { frontmatter, headings, collection } = Astro.props; -const { pathname } = Astro.url; +let { pathname } = Astro.url; +if (pathname.split('')[pathname.length - 1] === '/') pathname = pathname.substring(0, pathname.length - 1); const items = await getCollection(collection) || []; const description = await markdown.parse(frontmatter.description); const isActive = (href: string)=>{ - if (href[href.length - 1] === '/') href.split('').pop().join(''); + if (pathname.split('')[pathname.length - 1] === '/') { + pathname = pathname.split(''); + pathname.pop(); + pathname = pathname.join(''); + } + console.log(pathname); + + return href === pathname || href === pathname.split('/').slice(0,2).join('/'); }