From c8d728e1eda094ac570f34b67004d100b2596ecb Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 31 Mar 2024 18:17:09 -0300 Subject: content: linkExternal: tweak generate layout for nicer refactoring --- src/content/dependencies/linkExternal.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/content/dependencies') 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); }, }; -- cgit 1.3.0-6-gf8a5