diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-02 12:37:30 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-08-02 12:37:30 -0300 |
commit | aa69e214f604d895abc0cb88675f9b907b2f83a6 (patch) | |
tree | 4e8d5a80522c0edca68910931b20574f3f272f0e /src/content | |
parent | 99a56f31caa964081b1a3a1d0749812d804b40cb (diff) |
content, test: generatePreviousNextLinks: disable ID, fix null slots
* New slot to disable id attribute, so component is more versatile * Fixes including false in return array for null previous/next slots
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/dependencies/generatePreviousNextLinks.js | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/content/dependencies/generatePreviousNextLinks.js b/src/content/dependencies/generatePreviousNextLinks.js index 6cffcef4..e3417cb8 100644 --- a/src/content/dependencies/generatePreviousNextLinks.js +++ b/src/content/dependencies/generatePreviousNextLinks.js @@ -8,25 +8,32 @@ export default { slots: { previousLink: {type: 'html'}, nextLink: {type: 'html'}, + id: {type: 'boolean', default: true}, }, generate(slots, {html, language}) { - return [ - !html.isBlank(slots.previousLink) && + const previousNext = []; + + if (!html.isBlank(slots.previousLink)) { + previousNext.push( slots.previousLink.slots({ tooltip: true, color: false, - attributes: {id: 'previous-button'}, + attributes: {id: slots.id && 'previous-button'}, content: language.$('misc.nav.previous'), - }), + })); + } - !html.isBlank(slots.nextLink) && - slots.nextLink?.slots({ + if (!html.isBlank(slots.nextLink)) { + previousNext.push( + slots.nextLink.slots({ tooltip: true, color: false, - attributes: {id: 'next-button'}, + attributes: {id: slots.id && 'next-button'}, content: language.$('misc.nav.next'), - }), - ]; + })); + } + + return previousNext; }, }; |