From aa69e214f604d895abc0cb88675f9b907b2f83a6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 2 Aug 2023 12:37:30 -0300 Subject: 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 --- .../dependencies/generatePreviousNextLinks.js | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/content') 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; }, }; -- cgit 1.3.0-6-gf8a5