improve post nav

master
Aevann 2024-04-29 05:52:05 +03:00
parent b020f8a300
commit 8d10bf224a
2 changed files with 10 additions and 8 deletions

View File

@ -14,9 +14,13 @@ if (post_permalinks) {
pid = permalink_after.split('/').slice(-2, -1)[0] pid = permalink_after.split('/').slice(-2, -1)[0]
} }
function go_next() {
location.replace(permalink_after.slice(1, -1))
}
for (const btn of document.getElementsByClassName('post_navigation')) { for (const btn of document.getElementsByClassName('post_navigation')) {
btn.classList.remove('d-none') btn.classList.remove('d-none')
btn.href = permalink_after.slice(1, -1) btn.onclick = go_next
} }
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
@ -26,9 +30,7 @@ if (post_permalinks) {
!expandImageModal.classList.contains('show') !expandImageModal.classList.contains('show')
) { ) {
if (["ArrowRight", "d"].includes(e.key)) if (["ArrowRight", "d"].includes(e.key))
location.href = permalink_after.slice(1, -1) go_next()
if (["ArrowLeft", "a"].includes(e.key))
history.back()
} }
}) })
} }

View File

@ -200,9 +200,9 @@
{% endif %} {% endif %}
{% if p %} {% if p %}
<a class="post_navigation d-none mobile-nav-icon d-md-none" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Next Post"> <button class="post_navigation d-none mobile-nav-icon d-md-none" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Next Post">
<i class="fas fa-arrow-right align-middle text-gray-500 black"></i> <i class="fas fa-arrow-right align-middle text-gray-500 black"></i>
</a> </button>
{% endif %} {% endif %}
{% if g.browser == 'webview' %} {% if g.browser == 'webview' %}
@ -258,9 +258,9 @@
{% if p %} {% if p %}
<li class="nav-item d-flex align-items-center text-center justify-content-center mx-1"> <li class="nav-item d-flex align-items-center text-center justify-content-center mx-1">
<a class="post_navigation d-none nav-link" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Next Post"> <button class="post_navigation d-none nav-link" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Next Post">
<i class="fas fa-arrow-right"></i> <i class="fas fa-arrow-right"></i>
</a> </button>
</li> </li>
{% endif %} {% endif %}