mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
Fix trailing slash breadcrumb bug
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
---
|
---
|
||||||
const breadcrumbList = Astro.url.pathname.split("/").slice(1);
|
// Remove current url path and remove trailing slash if exists
|
||||||
|
const currentUrlPath = Astro.url.pathname.replace(/\/+$/, "");
|
||||||
|
|
||||||
|
// Get url array from path
|
||||||
|
// eg: /tags/tailwindcss => ['tags', 'tailwindcss']
|
||||||
|
const breadcrumbList = currentUrlPath.split("/").slice(1);
|
||||||
|
|
||||||
// if breadcrumb is Home > Post > 'article-name'
|
// if breadcrumb is Home > Post > 'article-name'
|
||||||
// replace 'article-name' to 'current post'
|
// replace 'article-name' to 'current post'
|
||||||
|
|||||||
Reference in New Issue
Block a user