mirror of
https://github.com/tauri-apps/tauri-docs.git
synced 2026-01-31 00:35:16 +01:00
add navigator script
Signed-off-by: Lorenzo Lewis <lorenzo_lewis@icloud.com>
This commit is contained in:
@@ -123,6 +123,12 @@ export default defineConfig({
|
||||
editLink: {
|
||||
baseUrl: 'https://github.com/tauri-apps/tauri-docs/edit/starlight',
|
||||
},
|
||||
head: [
|
||||
{
|
||||
tag: 'script',
|
||||
attrs: { src: '/javascript/navigator.js' },
|
||||
},
|
||||
],
|
||||
customCss: ['./src/styles/custom.css'],
|
||||
sidebar: [
|
||||
{
|
||||
|
||||
27
public/javascript/navigator.js
Normal file
27
public/javascript/navigator.js
Normal file
@@ -0,0 +1,27 @@
|
||||
(function chapterNavigation() {
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (window.search && window.search.hasFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.key) {
|
||||
case 'ArrowRight':
|
||||
e.preventDefault();
|
||||
var nextButton = document.querySelector('a[rel="next"]');
|
||||
if (nextButton) {
|
||||
window.location.href = nextButton.href;
|
||||
}
|
||||
break;
|
||||
case 'ArrowLeft':
|
||||
e.preventDefault();
|
||||
var previousButton = document.querySelector('a[rel="prev"]');
|
||||
if (previousButton) {
|
||||
window.location.href = previousButton.href;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user