diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-08-14 13:03:39 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-02 22:25:46 -0300 |
commit | e77262e34657164b5c194d2e639ff4ce627134a9 (patch) | |
tree | f64a67f47990bf50bbfa0b78b4b5e65eda7596a2 | |
parent | 7c5939aefafc88201eb73ba67a35d4de77c94d7a (diff) |
content, css, client: inert previous/next links
-rw-r--r-- | src/content/dependencies/generatePreviousNextLink.js | 51 | ||||
-rw-r--r-- | src/static/css/site.css | 4 | ||||
-rw-r--r-- | src/static/js/client/scripted-link.js | 9 |
3 files changed, 47 insertions, 17 deletions
diff --git a/src/content/dependencies/generatePreviousNextLink.js b/src/content/dependencies/generatePreviousNextLink.js index 9fe04aed..1c1bf27c 100644 --- a/src/content/dependencies/generatePreviousNextLink.js +++ b/src/content/dependencies/generatePreviousNextLink.js @@ -15,21 +15,42 @@ export default { type: 'boolean', default: true, }, + + showWithoutLink: { + type: 'boolean', + default: true, + }, }, - generate: (slots, {html, language}) => - (html.isBlank(slots.link) || !slots.direction - ? html.blank() - : slots.link.slots({ - tooltipStyle: 'browser', - color: false, - - attributes: - (slots.id - ? {id: `${slots.direction}-button`} - : null), - - content: - language.$('misc.nav', slots.direction), - })), + generate(slots, {html, language}) { + if (!slots.direction) { + return html.blank(); + } + + const attributes = html.attributes(); + + if (slots.id) { + attributes.set('id', `${slots.direction}-button`); + } + + if (html.isBlank(slots.link)) { + if (slots.showWithoutLink) { + return ( + html.tag('a', {class: 'inert-previous-next-link'}, + attributes, + language.$('misc.nav', slots.direction))); + } else { + return html.blank(); + } + } + + return slots.link.slots({ + tooltipStyle: 'browser', + color: false, + attributes, + + content: + language.$('misc.nav', slots.direction), + }); + }, }; diff --git a/src/static/css/site.css b/src/static/css/site.css index aa41746b..a46c0927 100644 --- a/src/static/css/site.css +++ b/src/static/css/site.css @@ -870,6 +870,10 @@ a:not([href]):hover { text-align: center; } +.inert-previous-next-link { + opacity: 0.7; +} + .nowrap { white-space: nowrap; } diff --git a/src/static/js/client/scripted-link.js b/src/static/js/client/scripted-link.js index 5db86e13..ca1c2548 100644 --- a/src/static/js/client/scripted-link.js +++ b/src/static/js/client/scripted-link.js @@ -190,11 +190,16 @@ export function mutatePageContent() { } function mutateNavigationLinkContent() { - const prependTitle = (el, prepend) => - el?.setAttribute('title', + const prependTitle = (el, prepend) => { + if (!el) return; + if (!el.hasAttribute('href')) return; + + el?.setAttribute( + 'title', (el.hasAttribute('title') ? prepend + ' ' + el.getAttribute('title') : prepend)); + }; prependTitle(info.nextNavLink, '(Shift+N)'); prependTitle(info.previousNavLink, '(Shift+P)'); |