diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-06-12 15:54:24 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-06-12 15:54:24 -0300 |
commit | 630af0a345f3be6c3e4aa3300ce138e48ed5ae91 (patch) | |
tree | 91cc3c76cebf93bf1042e89c05bc8f8d8442aff9 /src/content/dependencies/linkThing.js | |
parent | 0e150bbdf4c384bd2eee6fe3e06ab7b4eb3563da (diff) | |
parent | 05df0a1199dca320e0c8b92d210e6ab6e9676dfb (diff) |
Merge branch 'data-steps' of github.com:hsmusic/hsmusic-wiki into data-steps
Diffstat (limited to 'src/content/dependencies/linkThing.js')
-rw-r--r-- | src/content/dependencies/linkThing.js | 124 |
1 files changed, 61 insertions, 63 deletions
diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js index 4ccdf58d..03aa9836 100644 --- a/src/content/dependencies/linkThing.js +++ b/src/content/dependencies/linkThing.js @@ -25,70 +25,68 @@ export default { }; }, - generate(data, relations, {html}) { + slots: { + // content: relations.linkTemplate.getSlotDescription('content'), + content: {type: 'html'}, + + preferShortName: {type: 'boolean', default: false}, + + tooltip: { + validate: v => v.oneOf(v.isBoolean, v.isString), + default: false, + }, + + color: { + validate: v => v.oneOf(v.isBoolean, v.isColor), + default: true, + }, + + anchor: {type: 'boolean', default: false}, + + // attributes: relations.linkTemplate.getSlotDescription('attributes'), + // hash: relations.linkTemplate.getSlotDescription('hash'), + attributes: {validate: v => v.isAttributes}, + hash: {type: 'string'}, + }, + + generate(data, relations, slots, {html}) { const path = [data.pathKey, data.directory]; - return html.template({ - annotation: 'linkThing', - - slots: { - content: relations.linkTemplate.getSlotDescription('content'), - preferShortName: {type: 'boolean', default: false}, - - tooltip: { - validate: v => v.oneOf(v.isBoolean, v.isString), - default: false, - }, - - color: { - validate: v => v.oneOf(v.isBoolean, v.isColor), - default: true, - }, - - anchor: {type: 'boolean', default: false}, - - attributes: relations.linkTemplate.getSlotDescription('attributes'), - hash: relations.linkTemplate.getSlotDescription('hash'), - }, - - content(slots) { - let content = slots.content; - - const name = - (slots.preferShortName - ? data.nameShort ?? data.name - : data.name); - - if (html.isBlank(content)) { - content = name; - } - - let color = null; - if (slots.color === true) { - color = data.color ?? null; - } else if (typeof slots.color === 'string') { - color = slots.color; - } - - let tooltip = null; - if (slots.tooltip === true) { - tooltip = name; - } else if (typeof slots.tooltip === 'string') { - tooltip = slots.tooltip; - } - - return relations.linkTemplate - .slots({ - path: slots.anchor ? [] : path, - href: slots.anchor ? '' : null, - content, - color, - tooltip, - - attributes: slots.attributes, - hash: slots.hash, - }); - }, - }); + let content = slots.content; + + const name = + (slots.preferShortName + ? data.nameShort ?? data.name + : data.name); + + if (html.isBlank(content)) { + content = name; + } + + let color = null; + if (slots.color === true) { + color = data.color ?? null; + } else if (typeof slots.color === 'string') { + color = slots.color; + } + + let tooltip = null; + if (slots.tooltip === true) { + tooltip = name; + } else if (typeof slots.tooltip === 'string') { + tooltip = slots.tooltip; + } + + return relations.linkTemplate + .slots({ + path: slots.anchor ? [] : path, + href: slots.anchor ? '' : null, + content, + color, + tooltip, + + attributes: slots.attributes, + hash: slots.hash, + }); }, } |