File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 4343 </ main >
4444
4545 {{ partial "docs/inject/body" . }}
46+ < script src ="{{ .Site.BaseURL }}js/navlinks.js "> </ script >
4647</ body >
4748</ html >
4849
Original file line number Diff line number Diff line change 2222 < li >
2323 {{ if ne $currentPageIndex $prevLinkIndex }}
2424 {{$prevPage := index $sitePages $prevLinkIndex}}
25- < a href ="{{ $prevPage.Link }} "> {{ i18n "prev" }}</ a >
25+ < a href ="{{ $prevPage.Link }} " id =" prev-page " > {{ i18n "prev" }}</ a >
2626 {{ end }}
2727 </ li >
2828 < li >
2929 {{ if ne $currentPageIndex $nextLinkIndex }}
3030 {{$nextPage := index $sitePages $nextLinkIndex}}
31- < a href ="{{ $nextPage.Link }} "> {{ i18n "next"}}</ a >
31+ < a href ="{{ $nextPage.Link }} " id =" next-page " > {{ i18n "next"}}</ a >
3232 {{ end }}
3333 </ li >
3434</ ul >
Original file line number Diff line number Diff line change 1+ /**
2+ * Script to handle the navigation links events.
3+ * When the user presses arrow left or arrow right, the page will be redirected to the previous/next page if corresponding link exists.
4+ */
5+
6+ // Get the previous (id="prev-page") and next (id="next-page") links
7+ const prevPageLink = document . getElementById ( "prev-page" ) ;
8+ const nextPageLink = document . getElementById ( "next-page" ) ;
9+
10+ // Add event listener to the document
11+ document . addEventListener ( "keydown" , ( event ) => {
12+ if ( ! event . ctrlKey && ! event . altKey && ! event . shiftKey && ! event . metaKey ) {
13+ return ;
14+ } else {
15+ if ( event . key === "ArrowLeft" && prevPageLink ) {
16+ prevPageLink . click ( ) ;
17+ }
18+ if ( event . key === "ArrowRight" && nextPageLink ) {
19+ nextPageLink . click ( ) ;
20+ }
21+ }
22+ } ) ;
You can’t perform that action at this time.
0 commit comments