summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorAditya Telange <21258296+adityatelange@users.noreply.github.com>2020-12-05 20:16:04 +0530
committerAditya Telange <21258296+adityatelange@users.noreply.github.com>2020-12-05 20:17:07 +0530
commit80954de8bd085a3d5876e86c878088f911307c52 (patch)
tree9fc7a810bc72c5ba4f2672867fdbabc47de55edb /layouts
parentd4b259cd63b0e93c1e7c840b9e18b85f85dfd551 (diff)
anchored-headings: retain anchor link '#' in URL
close: #108
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/partials/footer.html8
2 files changed, 7 insertions, 3 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 6036e19..183d1a7 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -12,7 +12,7 @@
{{- if eq $.Site.Params.defaultTheme `dark` -}}
{{- print " dark" }}
{{- end -}}
-" id="top">
+">
{{- partialCached "header.html" . .Page}}
<main class="main">
{{- block "main" . }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 3af7105..76d8e49 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -9,7 +9,7 @@
<span>&middot;</span>
<span>Theme <a href="https://git.io/hugopapermod" rel="noopener" target="_blank">PaperMod</a></span>
</footer>
-<a href="#top" aria-label="go to top" title="Go to Top" accesskey="g">
+<a aria-label="go to top" title="Go to Top" accesskey="g">
<button class="top-link" id="top-link" type="button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6">
<path d="M12 6H0l6-6z" /></svg>
@@ -34,7 +34,6 @@
}
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function (e) {
- e.preventDefault();
var id = this.getAttribute("href").substr(1);
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
behavior: "smooth"
@@ -51,6 +50,11 @@
mybutton.style.opacity = "0";
}
};
+ mybutton.onclick = function () {
+ document.body.scrollTop = 0;
+ document.documentElement.scrollTop = 0;
+ window.location.hash = ''
+ }
function menu_on_scroll() {
localStorage.setItem("menu-scroll-position", document.getElementById('menu').scrollLeft);