chore(astro): upgrade to Astro 6 and fix dynamic collection routes
This commit is contained in:
@@ -11,7 +11,8 @@ const {
|
||||
const entries = (await getCollection(collection))
|
||||
.sort((a, b) => (a.data.order ?? 0) - (b.data.order ?? 0));
|
||||
|
||||
const href = (slug) => `${basePath}/${slug}/`;
|
||||
const routeSlug = (entry) => String(entry.id || "").replace(/\.(md|mdx)$/i, "");
|
||||
const href = (entry) => `${basePath}/${routeSlug(entry)}/`;
|
||||
---
|
||||
|
||||
<nav class="toc-global" aria-label={label}>
|
||||
@@ -21,10 +22,12 @@ const href = (slug) => `${basePath}/${slug}/`;
|
||||
|
||||
<ol class="toc-global__list">
|
||||
{entries.map((e) => {
|
||||
const active = e.slug === currentSlug;
|
||||
const entrySlug = routeSlug(e);
|
||||
const active = entrySlug === currentSlug;
|
||||
|
||||
return (
|
||||
<li class={`toc-item ${active ? "is-active" : ""}`}>
|
||||
<a class="toc-link" href={href(e.slug)} aria-current={active ? "page" : undefined}>
|
||||
<a class="toc-link" href={href(e)} aria-current={active ? "page" : undefined}>
|
||||
<span class="toc-link__row">
|
||||
{active ? (
|
||||
<span class="toc-active-indicator" aria-hidden="true">👉</span>
|
||||
|
||||
Reference in New Issue
Block a user