Skip to content

Commit

Permalink
Drop AnchorJS in favor of Hugo markdown render hook (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
deining committed Mar 7, 2023
1 parent dd32822 commit 247ccfd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 51 deletions.
49 changes: 0 additions & 49 deletions assets/js/anchor.js

This file was deleted.

3 changes: 3 additions & 0 deletions layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h{{ .Level }} id="{{- .Anchor | safeURL -}}" onmouseenter="this.firstElementChild.style.visibility='visible';" onmouseleave="this.firstElementChild.style.visibility='hidden';">{{ .Text | safeHTML }}
<a class="header-link" href="#{{ .Anchor | safeURL }}" style="visibility: hidden;"><svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg></a>
</h{{ .Level }}>
3 changes: 1 addition & 2 deletions layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@

{{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}}
{{ $jsBase := resources.Get "js/base.js" -}}
{{ $jsAnchor := resources.Get "js/anchor.js" -}}
{{ $jsSearch := resources.Get "js/search.js" | resources.ExecuteAsTemplate "js/search.js" .Site.Home -}}
{{ $jsMermaid := resources.Get "js/mermaid.js" | resources.ExecuteAsTemplate "js/mermaid.js" . -}}
{{ $jsMarkmap := resources.Get "js/markmap.js" | resources.ExecuteAsTemplate "js/markmap.js" . -}}
Expand All @@ -74,7 +73,7 @@
{{ $jsSearch = resources.Get "js/offline-search.js" -}}
{{ end -}}

{{ $jsArray := slice $jsBs $jsBase $jsAnchor $jsSearch $jsPlantuml $jsMarkmap $jsDrawio -}}
{{ $jsArray := slice $jsBs $jsBase $jsSearch $jsPlantuml $jsMarkmap $jsDrawio -}}

{{ if $needmermaid -}}
{{ $jsArray = $jsArray | append $jsMermaid -}}
Expand Down

0 comments on commit 247ccfd

Please sign in to comment.