diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-08 21:38:29 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-08-08 21:38:29 -0300 |
commit | f9247a3a21abd26ae22d769d2da7d4ce6e99461d (patch) | |
tree | 7d81d8b328cda2384c49a212b09b97561422ddc3 /src/content/dependencies | |
parent | f484c6e9ea62baad8818864e715f8a435fddc241 (diff) |
content: transformContent: "dynamically" detect slot availability
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/transformContent.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js index 8494738c..93669cc1 100644 --- a/src/content/dependencies/transformContent.js +++ b/src/content/dependencies/transformContent.js @@ -189,14 +189,12 @@ export default { determineData: { // No value at all: this is an index link. if (!replacerValue || replacerValue === '-') { - data.toIndex = true; break determineData; } // Nothing to find: the link operates on a path or string, not a data object. if (!spec.find) { data.value = replacerValue; - data.toIndex = false; break determineData; } @@ -214,7 +212,6 @@ export default { // Something was found: the link operates on that thing. data.thing = thing; - data.toIndex = false; } const {transformName} = spec; @@ -281,7 +278,6 @@ export default { link: relation(name, arg), label: node.data.label, hash: node.data.hash, - toIndex: node.data.toIndex, } : getPlaceholder(node, content)); @@ -376,7 +372,7 @@ export default { return {type: 'text', data: linkNode.data}; } - const {link, label, hash, toIndex} = linkNode; + const {link, label, hash} = linkNode; // These are removed from the typical combined slots({})-style // because we don't want to override slots that were already set @@ -385,7 +381,16 @@ export default { if (label) link.setSlot('content', label); if (hash) link.setSlot('hash', hash); - if (!toIndex) { + // TODO: This is obviously hacky. + let hasPreferShortNameSlot; + try { + link.getSlotDescription('preferShortName'); + hasPreferShortNameSlot = true; + } catch (error) { + hasPreferShortNameSlot = false; + } + + if (hasPreferShortNameSlot) { link.setSlot('preferShortName', slots.preferShortLinkNames); } |