diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index df2066e..4aa78ce 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -43,6 +43,7 @@ {{ partial "docs/inject/body" . }} + diff --git a/layouts/partials/docs/navigation-links.html b/layouts/partials/docs/navigation-links.html index 5a71f86..1cf4283 100644 --- a/layouts/partials/docs/navigation-links.html +++ b/layouts/partials/docs/navigation-links.html @@ -22,13 +22,13 @@
  • {{ if ne $currentPageIndex $prevLinkIndex }} {{$prevPage := index $sitePages $prevLinkIndex}} - {{ i18n "prev" }} + {{ i18n "prev" }} {{ end }}
  • {{ if ne $currentPageIndex $nextLinkIndex }} {{$nextPage := index $sitePages $nextLinkIndex}} - {{ i18n "next"}} + {{ i18n "next"}} {{ end }}
  • diff --git a/static/js/navlinks.js b/static/js/navlinks.js new file mode 100644 index 0000000..0671f25 --- /dev/null +++ b/static/js/navlinks.js @@ -0,0 +1,22 @@ +/** + * Script to handle the navigation links events. + * When the user presses arrow left or arrow right, the page will be redirected to the previous/next page if corresponding link exists. + */ + +// Get the previous (id="prev-page") and next (id="next-page") links +const prevPageLink = document.getElementById("prev-page"); +const nextPageLink = document.getElementById("next-page"); + +// Add event listener to the document +document.addEventListener("keydown", (event) => { + if (!event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey) { + return; + } else { + if (event.key === "ArrowLeft" && prevPageLink) { + prevPageLink.click(); + } + if (event.key === "ArrowRight" && nextPageLink) { + nextPageLink.click(); + } + } +});