diff options
author | 2021-09-04 19:55:55 -0500 | |
---|---|---|
committer | 2021-09-04 19:55:55 -0500 | |
commit | 73a98821b785e0de1e059d50bbdce402b3a8eaca (patch) | |
tree | 0c3b44563edddbd54fb2a2687ace4b350426e934 /docs/src/components/LeftSidebar/LeftSidebar.astro | |
parent | 02c38a0d3b1e71d2cb708c5ef2d2c472ca977e5a (diff) | |
download | astro-73a98821b785e0de1e059d50bbdce402b3a8eaca.tar.gz astro-73a98821b785e0de1e059d50bbdce402b3a8eaca.tar.zst astro-73a98821b785e0de1e059d50bbdce402b3a8eaca.zip |
📘DOC: Fix URL normalization for the Left Sidebar in docs (#1299)
* Fix URL normalization for the Left Sidebar in docs
* Move the fix into `util.ts` as suggested by @FredKSchott
Diffstat (limited to 'docs/src/components/LeftSidebar/LeftSidebar.astro')
-rw-r--r-- | docs/src/components/LeftSidebar/LeftSidebar.astro | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/src/components/LeftSidebar/LeftSidebar.astro b/docs/src/components/LeftSidebar/LeftSidebar.astro index 813de0cf7..1960dbb04 100644 --- a/docs/src/components/LeftSidebar/LeftSidebar.astro +++ b/docs/src/components/LeftSidebar/LeftSidebar.astro @@ -1,8 +1,10 @@ --- import { SIDEBAR } from '../../config.ts'; -import { getLanguageFromURL } from '../../util.ts'; +import { getLanguageFromURL, removeLeadingSlash, removeTrailingSlash } from '../../util.ts'; const {currentPage} = Astro.props; -const currentPageMatch = currentPage.slice(1); + +// Get the slug w/o a leading or trailing slash +const currentPageMatch = removeLeadingSlash(removeTrailingSlash(currentPage)); const langCode = getLanguageFromURL(currentPage); // SIDEBAR is a flat array. Group it by sections to properly render. const sidebarSections = SIDEBAR[langCode].reduce((col, item) => { |