From 33fbdc1b5e70c0b8d3b8a71bacf3436e543c617a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 8 Dec 2023 20:06:58 -0400 Subject: content: linkThing: support providing path externally --- src/content/dependencies/linkThing.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src') 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 -- cgit 1.3.0-6-gf8a5