diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-12-08 20:06:58 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-12-28 17:14:14 -0400 |
commit | 33fbdc1b5e70c0b8d3b8a71bacf3436e543c617a (patch) | |
tree | e6686e18e3e09621820ce3b956d6b6dd574d1b11 | |
parent | 479ac8741f6be49c3493b85e46d2387f63a02a7e (diff) |
content: linkThing: support providing path externally
-rw-r--r-- | src/content/dependencies/linkThing.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js index b20b132b..1dbd2148 100644 --- a/src/content/dependencies/linkThing.js +++ b/src/content/dependencies/linkThing.js @@ -9,15 +9,20 @@ export default { }, data(pathKey, thing) { - return { - pathKey, + const data = {}; - color: thing.color, - directory: thing.directory, + if (pathKey) { + data.pathKey = pathKey; + data.directory = thing.directory; + } else { + data.pathKey = null; + } - name: thing.name, - nameShort: thing.nameShort, - }; + data.color = thing.color; + data.name = thing.name; + data.nameShort = thing.nameShort ?? thing.shortName; + + return data; }, slots: { @@ -35,6 +40,8 @@ export default { default: true, }, + path: {validate: v => v.validateArrayItems(v.isString)}, + anchor: {type: 'boolean', default: false}, linkless: {type: 'boolean', default: false}, @@ -43,7 +50,12 @@ export default { }, generate(data, relations, slots, {html, language}) { - const path = [data.pathKey, data.directory]; + const path = + (slots.path + ? slots.path + : data.pathKey + ? [data.pathKey, data.directory] + : null); const name = (slots.preferShortName |