Skip to content

Commit

Permalink
Add identifier to sidebar links
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustMiller committed Dec 6, 2023
1 parent 173482f commit b2e6625
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/.vuepress/theme/components/SidebarLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export default {
};
function renderLink(h, to, text, active, level) {
const hashPosition = to.indexOf('#');
const path = to.substring(0, hashPosition > 0 ? hashPosition : to.length);
const segments = path.split('/');
const lastSegment = segments[segments.length - 1];
const handle = lastSegment.replace('.html', '');
const component = {
props: {
to,
Expand All @@ -69,6 +75,8 @@ function renderLink(h, to, text, active, level) {
class: {
active,
"sidebar-link": true,
// Include a “slug” identifier when this isn't a jump link:
[`slug-${handle || 'root'}`]: hashPosition < 0,
},
};
Expand Down

0 comments on commit b2e6625

Please sign in to comment.