Fixed prev/next page keyboard navigation when footer is not present

This commit is contained in:
squidfunk 2022-12-14 21:49:43 +01:00
parent 26c08f1f38
commit 763423d30b
14 changed files with 43 additions and 26 deletions

View File

@ -16,5 +16,5 @@
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script src="{{ 'assets/javascripts/custom.0099a353.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/custom.794c1817.min.js' | url }}"></script>
{% endblock %} {% endblock %}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,6 +21,12 @@
{% if page.canonical_url %} {% if page.canonical_url %}
<link rel="canonical" href="{{ page.canonical_url }}"> <link rel="canonical" href="{{ page.canonical_url }}">
{% endif %} {% endif %}
{% if page.previous_page %}
<link rel="prev" href="{{ page.previous_page.url | url }}">
{% endif %}
{% if page.next_page %}
<link rel="next" href="{{ page.next_page.url | url }}">
{% endif %}
<link rel="icon" href="{{ config.theme.favicon | url }}"> <link rel="icon" href="{{ config.theme.favicon | url }}">
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-material-9.0.0b4"> <meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-material-9.0.0b4">
{% endblock %} {% endblock %}
@ -234,13 +240,13 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.6d7e1051.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.94c06c99.min.js' | url }}"></script>
{% for path in config.extra_javascript %} {% for path in config.extra_javascript %}
<script src="{{ path | url }}"></script> <script src="{{ path | url }}"></script>
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
{% if page.meta and page.meta.ᴴₒᴴₒᴴₒ %} {% if page.meta and page.meta.ᴴₒᴴₒᴴₒ %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/extra.e916454c.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/extra.e437594a.min.css' | url }}">
<script src="{{ 'assets/javascripts/extra/bundle.cfb3feee.min.js' | url }}" defer></script> <script src="{{ 'assets/javascripts/extra/bundle.cfb3feee.min.js' | url }}" defer></script>
{% endif %} {% endif %}
</body> </body>

View File

@ -45,7 +45,7 @@ export function getLocation(): URL {
* *
* @param url - URL to change to * @param url - URL to change to
*/ */
export function setLocation(url: URL): void { export function setLocation(url: URL | HTMLLinkElement): void {
location.href = url.href location.href = url.href
} }

View File

@ -45,6 +45,7 @@ import {
at, at,
getOptionalElement, getOptionalElement,
requestJSON, requestJSON,
setLocation,
setToggle, setToggle,
watchDocument, watchDocument,
watchKeyboard, watchKeyboard,
@ -173,17 +174,17 @@ keyboard$
/* Go to previous page */ /* Go to previous page */
case "p": case "p":
case ",": case ",":
const prev = getOptionalElement("[href][rel=prev]") const prev = getOptionalElement<HTMLLinkElement>("link[rel=prev]")
if (typeof prev !== "undefined") if (typeof prev !== "undefined")
prev.click() setLocation(prev)
break break
/* Go to next page */ /* Go to next page */
case "n": case "n":
case ".": case ".":
const next = getOptionalElement("[href][rel=next]") const next = getOptionalElement<HTMLLinkElement>("link[rel=next]")
if (typeof next !== "undefined") if (typeof next !== "undefined")
next.click() setLocation(next)
break break
} }
}) })

View File

@ -50,6 +50,16 @@
<link rel="canonical" href="{{ page.canonical_url }}" /> <link rel="canonical" href="{{ page.canonical_url }}" />
{% endif %} {% endif %}
<!-- Previous page -->
{% if page.previous_page %}
<link rel="prev" href="{{ page.previous_page.url | url }}" />
{% endif %}
<!-- Next page -->
{% if page.next_page %}
<link rel="next" href="{{ page.next_page.url | url }}" />
{% endif %}
<!-- Favicon --> <!-- Favicon -->
<link rel="icon" href="{{ config.theme.favicon | url }}" /> <link rel="icon" href="{{ config.theme.favicon | url }}" />