diff options
author | Darshan Baral <darshanbaral@users.noreply.github.com> | 2020-04-24 21:19:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 21:19:29 +0300 |
commit | 23df198d88e1133a578f33248c6ac1835d70bdd7 (patch) | |
tree | f63bd8cdedd8781f464cc804f618d1391277c197 | |
parent | f2a6c838b9b12a9909c1ac83b6dc3c2aed104425 (diff) | |
parent | 1cb017191320496f3390107af144a87dd7b9c6d9 (diff) |
Merge pull request #2 from darshanbaral/alt-animation-in-home
keyboard navigation for list page
-rw-r--r-- | layouts/_default/list.html | 40 | ||||
-rw-r--r-- | layouts/index.html | 1 |
2 files changed, 35 insertions, 6 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index e020f51..f76389a 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -7,18 +7,48 @@ <div>
{{ range (.Paginator .Site.Params.theme.paginateNum).Pages }}
<div
- style="border: solid 1px; margin: 30px 0; padding: 10px; border-radius: 5px; background-color: var(--bgAltColor);"
+ style="
+ border: solid 1px;
+ margin: 30px 0;
+ padding: 10px;
+ border-radius: 5px;
+ background-color: var(--bgAltColor);
+ "
>
<a href="{{ .Permalink | relURL }}">
<h2 style="margin: 0; font-size: 1.2em;">{{ .Title -}}</h2>
</a>
<span style="font-size: 0.65em; font-style: italic;"
- ><time
- >{{- dateFormat .Site.Params.theme.dateFormat .Date }}</time
- > · {{.Site.Params.author }}</span
+ ><time>{{- dateFormat .Site.Params.theme.dateFormat .Date }}</time>
+ · {{.Site.Params.author }}</span
>
- <p style="margin: 0; font-size: 0.8em;">{{ substr .Summary 0 125 | plainify }}...</p>
+ <p style="margin: 0; font-size: 0.8em;">
+ {{ .Summary | plainify | truncate 180 }}
+ </p>
</div>
{{ end }}
</div>
+<script>
+ document.onkeydown = function (e) {
+ const thisPage = document.querySelector(".page-item.active");
+ if (thisPage) {
+ switch (e.keyCode) {
+ case 37:
+ //left key
+ let previousPage = thisPage.previousElementSibling.querySelector("a");
+ if (previousPage) {
+ previousPage.click();
+ }
+ break;
+ case 39:
+ //right key
+ let nextPage = thisPage.nextElementSibling.querySelector("a");
+ if (nextPage) {
+ nextPage.click();
+ }
+ break;
+ }
+ }
+ };
+</script>
{{ end }}
diff --git a/layouts/index.html b/layouts/index.html index 84625a1..ce5598a 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -50,7 +50,6 @@ opacity: 1;
visibility: visible;
transition: opacity 0.8s, width 0.8s, transform 0.8s;
- cursor: pointer;
width: 100%;
transform: none;
"
|