diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-29 19:07:47 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-03-29 20:41:54 -0300 |
commit | 68a062d92a07969ceb89075be979e1acdbeb679c (patch) | |
tree | 305b0089b9c505a6c76cd74a09487c60aea09b7c /src/content/dependencies | |
parent | 7d3169246f31234c2f182480b281f9fa93d0c431 (diff) |
content: linkExternal: fall back to 'platform' style
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/linkExternal.js | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js index 282fb76c..f0947cb7 100644 --- a/src/content/dependencies/linkExternal.js +++ b/src/content/dependencies/linkExternal.js @@ -25,16 +25,32 @@ export default { }, }, - generate: (data, slots, {html, language}) => - html.tag('a', - {href: data.url}, - {class: 'nowrap'}, - - slots.tab === 'separate' && - {target: '_blank'}, - + generate(data, slots, {html, language}) { + let formattedText = language.formatExternalLink(data.url, { style: slots.style, context: slots.context, - })), + }); + + // Fall back to platform if nothing matched the desired style. + if (!formattedText && slots.style !== 'platform') { + formattedText = + language.formatExternalLink(data.url, { + style: 'platform', + context: slots.context, + }); + } + + const link = + html.tag('a', formattedText); + + link.attributes.set('href', data.url); + link.attributes.set('class', 'nowrap'); + + if (slots.tab === 'separate') { + link.attributes.set('target', '_blank'); + } + + return link; + }, }; |