diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-31 18:17:09 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-03-31 19:08:09 -0300 |
commit | c8d728e1eda094ac570f34b67004d100b2596ecb (patch) | |
tree | 2899d8c75d5aae4866a5a0dca4c892919c0378b0 /src/content | |
parent | badf0e751a24c55c0c5b7e13674ca71aa0287664 (diff) |
content: linkExternal: tweak generate layout for nicer refactoring
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/dependencies/linkExternal.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js index afdfe6ef..9469a9e9 100644 --- a/src/content/dependencies/linkExternal.js +++ b/src/content/dependencies/linkExternal.js @@ -26,31 +26,30 @@ export default { }, generate(data, slots, {html, language}) { - let formattedText = + const linkAttributes = html.attributes(); + + let linkContent = language.formatExternalLink(data.url, { style: slots.style, context: slots.context, }); // Fall back to platform if nothing matched the desired style. - if (html.isBlank(formattedText) && slots.style !== 'platform') { - formattedText = + if (html.isBlank(linkContent) && slots.style !== 'platform') { + linkContent = 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'); + linkAttributes.set('href', data.url); + linkAttributes.set('class', 'nowrap'); if (slots.tab === 'separate') { - link.attributes.set('target', '_blank'); + linkAttributes.set('target', '_blank'); } - return link; + return html.tag('a', linkAttributes, linkContent); }, }; |