Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop AnchorJS in favor of Hugo markdown render hook #1463

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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