From f500eb7b8cc8b17785dd098934505bfcbca4e98f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 1 Mar 2024 07:38:54 -0400 Subject: linkExternal: add content slot There's not necessarily a use for linkExternal with content slot on its own as of this commit, compared to a normal html.tag('a'), because linkExternal basically just wraps formatExternalLink and the content slot opts out of using that. But this does allow this component to be used in places now... and extended upon... later! --- src/content/dependencies/linkExternal.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js index 9469a9e..2de1bc7 100644 --- a/src/content/dependencies/linkExternal.js +++ b/src/content/dependencies/linkExternal.js @@ -6,6 +6,11 @@ export default { data: (url) => ({url}), slots: { + content: { + type: 'html', + mutable: false, + }, + style: { // This awkward syntax is because the slot descriptor validator can't // differentiate between a function that returns a validator (the usual @@ -27,12 +32,15 @@ export default { generate(data, slots, {html, language}) { const linkAttributes = html.attributes(); + let linkContent = slots.content; - let linkContent = - language.formatExternalLink(data.url, { - style: slots.style, - context: slots.context, - }); + if (html.isBlank(linkContent)) { + linkContent = + language.formatExternalLink(data.url, { + style: slots.style, + context: slots.context, + }); + } // Fall back to platform if nothing matched the desired style. if (html.isBlank(linkContent) && slots.style !== 'platform') { -- cgit 1.3.0-6-gf8a5