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 %}
{% block scripts %}
{{ super() }}
<script src="{{ 'assets/javascripts/custom.0099a353.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/custom.794c1817.min.js' | url }}"></script>
{% 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 %}
<link rel="canonical" href="{{ page.canonical_url }}">
{% 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 }}">
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-material-9.0.0b4">
{% endblock %}
@ -234,13 +240,13 @@
</script>
{% endblock %}
{% 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 %}
<script src="{{ path | url }}"></script>
{% endfor %}
{% endblock %}
{% 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>
{% endif %}
</body>

View File

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

View File

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

View File

@ -50,6 +50,16 @@
<link rel="canonical" href="{{ page.canonical_url }}" />
{% 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 -->
<link rel="icon" href="{{ config.theme.favicon | url }}" />