diff options
Diffstat (limited to 'src/content/dependencies/generatePreviousNextLink.js')
-rw-r--r-- | src/content/dependencies/generatePreviousNextLink.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/content/dependencies/generatePreviousNextLink.js b/src/content/dependencies/generatePreviousNextLink.js new file mode 100644 index 00000000..afae1228 --- /dev/null +++ b/src/content/dependencies/generatePreviousNextLink.js @@ -0,0 +1,58 @@ +export default { + extraDependencies: ['html', 'language'], + + slots: { + link: { + type: 'html', + mutable: true, + }, + + direction: { + validate: v => v.is('previous', 'next'), + }, + + id: { + type: 'boolean', + default: true, + }, + + showWithoutLink: { + type: 'boolean', + default: true, + }, + }, + + 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 html.resolve(slots.link, { + slots: { + tooltipStyle: 'browser', + color: false, + attributes, + + content: + language.$('misc.nav', slots.direction), + } + }); + }, +}; |