Merge pull request 'EditionToc Modif' (#215) from chore/astro6-upgrade into main
Reviewed-on: #215
This commit was merged in pull request #215.
This commit is contained in:
@@ -11,7 +11,8 @@ const {
|
|||||||
const entries = (await getCollection(collection))
|
const entries = (await getCollection(collection))
|
||||||
.sort((a, b) => (a.data.order ?? 0) - (b.data.order ?? 0));
|
.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}>
|
<nav class="toc-global" aria-label={label}>
|
||||||
@@ -21,10 +22,12 @@ const href = (slug) => `${basePath}/${slug}/`;
|
|||||||
|
|
||||||
<ol class="toc-global__list">
|
<ol class="toc-global__list">
|
||||||
{entries.map((e) => {
|
{entries.map((e) => {
|
||||||
const active = e.slug === currentSlug;
|
const entrySlug = routeSlug(e);
|
||||||
|
const active = entrySlug === currentSlug;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li class={`toc-item ${active ? "is-active" : ""}`}>
|
<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">
|
<span class="toc-link__row">
|
||||||
{active ? (
|
{active ? (
|
||||||
<span class="toc-active-indicator" aria-hidden="true">👉</span>
|
<span class="toc-active-indicator" aria-hidden="true">👉</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user