add .current to the current link

This commit is contained in:
Amagi:DDmxh 2023-08-11 00:21:39 +08:00
parent 254e415a61
commit 70d8ddacf1
2 changed files with 13 additions and 2 deletions

View file

@ -7,4 +7,16 @@
{{end}} {{end}}
<script type="text/javascript">window.CaddyfileDirectives = {{$directives | toJson}};</script> <script type="text/javascript">window.CaddyfileDirectives = {{$directives | toJson}};</script>
<script src="/resources/js/jquery-3.4.1.min.js"></script> <script src="/resources/js/jquery-3.4.1.min.js"></script>
<script src="/resources/js/docs.js"></script> <script src="/resources/js/docs.js"></script>
<script type="text/javascript">
$(function(){
var current = location.pathname;
$('header > nav a').each(function(){
var $this = $(this);
// if the current path is like this link, make it active
if (current.indexOf($this.attr('href')) !== -1) {
$this.addClass('current');
}
})
})
</script>

View file

@ -1,4 +1,3 @@
<!--TODO: add class="current" to the current link-->
<nav> <nav>
<div id="search"></div> <div id="search"></div>
<a href="/v2">v2 <span class="new">new</span></a> <a href="/v2">v2 <span class="new">new</span></a>