From bee8e687a3e332203d31ad88a107f1ec9fa125aa Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 29 Mar 2023 18:05:32 -0300 Subject: content: generateIconForURL -> linkExternalAsIcon --- .../dependencies/generateContributionLinks.js | 4 +- src/content/dependencies/generateIconForURL.js | 51 ---------------------- src/content/dependencies/linkExternalAsIcon.js | 51 ++++++++++++++++++++++ 3 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 src/content/dependencies/generateIconForURL.js create mode 100644 src/content/dependencies/linkExternalAsIcon.js (limited to 'src') diff --git a/src/content/dependencies/generateContributionLinks.js b/src/content/dependencies/generateContributionLinks.js index 18bc409d..c035c271 100644 --- a/src/content/dependencies/generateContributionLinks.js +++ b/src/content/dependencies/generateContributionLinks.js @@ -3,7 +3,7 @@ import {empty} from '../../util/sugar.js'; export default { contentDependencies: [ 'linkArtist', - 'generateIconForURL', + 'linkExternalAsIcon', ], extraDependencies: [ @@ -21,7 +21,7 @@ export default { relations.artistIcons = contributions.map(({who}) => who.urls.map(url => - relation('generateIconForURL', url))); + relation('linkExternalAsIcon', url))); } return relations; diff --git a/src/content/dependencies/generateIconForURL.js b/src/content/dependencies/generateIconForURL.js deleted file mode 100644 index 4473ccbf..00000000 --- a/src/content/dependencies/generateIconForURL.js +++ /dev/null @@ -1,51 +0,0 @@ -const BANDCAMP_DOMAINS = [ - 'bc.s3m.us', - 'music.solatrux.com', -]; - -const MASTODON_DOMAINS = [ - 'types.pl', -]; - -export default { - extraDependencies: ['html', 'language', 'to'], - - data(url) { - return {url}; - }, - - generate(data, {html, language, to}) { - const domain = new URL(data.url).hostname; - const [id, msg] = ( - domain.includes('bandcamp.com') - ? ['bandcamp', language.$('misc.external.bandcamp')] - : BANDCAMP_DOMAINS.includes(domain) - ? ['bandcamp', language.$('misc.external.bandcamp.domain', {domain})] - : MASTODON_DOMAINS.includes(domain) - ? ['mastodon', language.$('misc.external.mastodon.domain', {domain})] - : domain.includes('youtu') - ? ['youtube', language.$('misc.external.youtube')] - : domain.includes('soundcloud') - ? ['soundcloud', language.$('misc.external.soundcloud')] - : domain.includes('tumblr.com') - ? ['tumblr', language.$('misc.external.tumblr')] - : domain.includes('twitter.com') - ? ['twitter', language.$('misc.external.twitter')] - : domain.includes('deviantart.com') - ? ['deviantart', language.$('misc.external.deviantart')] - : domain.includes('instagram.com') - ? ['instagram', language.$('misc.external.bandcamp')] - : domain.includes('newgrounds.com') - ? ['newgrounds', language.$('misc.external.newgrounds')] - : ['globe', language.$('misc.external.domain', {domain})]); - - return html.tag('a', - {href: data.url, class: 'icon'}, - html.tag('svg', [ - html.tag('title', msg), - html.tag('use', { - href: to('shared.staticFile', `icons.svg#icon-${id}`), - }), - ])); - }, -}; diff --git a/src/content/dependencies/linkExternalAsIcon.js b/src/content/dependencies/linkExternalAsIcon.js new file mode 100644 index 00000000..4473ccbf --- /dev/null +++ b/src/content/dependencies/linkExternalAsIcon.js @@ -0,0 +1,51 @@ +const BANDCAMP_DOMAINS = [ + 'bc.s3m.us', + 'music.solatrux.com', +]; + +const MASTODON_DOMAINS = [ + 'types.pl', +]; + +export default { + extraDependencies: ['html', 'language', 'to'], + + data(url) { + return {url}; + }, + + generate(data, {html, language, to}) { + const domain = new URL(data.url).hostname; + const [id, msg] = ( + domain.includes('bandcamp.com') + ? ['bandcamp', language.$('misc.external.bandcamp')] + : BANDCAMP_DOMAINS.includes(domain) + ? ['bandcamp', language.$('misc.external.bandcamp.domain', {domain})] + : MASTODON_DOMAINS.includes(domain) + ? ['mastodon', language.$('misc.external.mastodon.domain', {domain})] + : domain.includes('youtu') + ? ['youtube', language.$('misc.external.youtube')] + : domain.includes('soundcloud') + ? ['soundcloud', language.$('misc.external.soundcloud')] + : domain.includes('tumblr.com') + ? ['tumblr', language.$('misc.external.tumblr')] + : domain.includes('twitter.com') + ? ['twitter', language.$('misc.external.twitter')] + : domain.includes('deviantart.com') + ? ['deviantart', language.$('misc.external.deviantart')] + : domain.includes('instagram.com') + ? ['instagram', language.$('misc.external.bandcamp')] + : domain.includes('newgrounds.com') + ? ['newgrounds', language.$('misc.external.newgrounds')] + : ['globe', language.$('misc.external.domain', {domain})]); + + return html.tag('a', + {href: data.url, class: 'icon'}, + html.tag('svg', [ + html.tag('title', msg), + html.tag('use', { + href: to('shared.staticFile', `icons.svg#icon-${id}`), + }), + ])); + }, +}; -- cgit 1.3.0-6-gf8a5