Skip to content

Commit 7a0d749

Browse files
authored
Open active link in navigation (#43)
* Add class to current active link and open parents * Style for active-link
1 parent affef70 commit 7a0d749

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/_sass/railsdoc.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ code {
102102
}
103103
}
104104

105+
.active-link {
106+
font-weight: bold;
107+
text-decoration: underline;
108+
}
109+
105110
.icon {
106111
cursor: pointer;
107112
background: url("/assets/image/arrow-right.svg");

src/assets/js/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ $(() => {
88

99
anchors.options.visible = 'always';
1010
anchors.add();
11+
12+
$(`.sidebar-content a[href='${window.location.pathname}']`)
13+
.attr("class", "active-link")
14+
.parents('ul').show();
1115
});

0 commit comments

Comments
 (0)