From 2a255b6c2e5970a523f9e2d6cf2b4d51dea97f06 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 26 Jul 2023 11:12:21 -0300 Subject: content: transformContent: single-link mode --- src/content/dependencies/generateWikiHomePage.js | 2 +- src/content/dependencies/transformContent.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/content/dependencies/generateWikiHomePage.js b/src/content/dependencies/generateWikiHomePage.js index 666c3f26..d3d05c40 100644 --- a/src/content/dependencies/generateWikiHomePage.js +++ b/src/content/dependencies/generateWikiHomePage.js @@ -80,7 +80,7 @@ export default { ?.map(content => ({ html: content.slots({ - mode: 'inline', + mode: 'single-link', preferShortLinkNames: true, }), })) diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js index ebb4e12a..03bd7bcc 100644 --- a/src/content/dependencies/transformContent.js +++ b/src/content/dependencies/transformContent.js @@ -186,7 +186,7 @@ export default { slots: { mode: { - validate: v => v.is('inline', 'multiline', 'lyrics'), + validate: v => v.is('inline', 'multiline', 'lyrics', 'single-link'), default: 'multiline', }, @@ -259,6 +259,19 @@ export default { return getPlaceholder(node, data.content); }); + // In single-link mode, return the link node exactly as is - exposing + // access to its slots. + + if (slots.mode === 'single-link') { + const link = contentFromNodes.find(node => node.type === 'link'); + + if (!link) { + return html.blank(); + } + + return link.data; + } + // In inline mode, no further processing is needed! if (slots.mode === 'inline') { -- cgit 1.3.0-6-gf8a5