« get me outta code hell

generateExternalIcon.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateExternalIcon.js
blob: 637af6587a2b112b4ad7f46068379e86942708f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import {isExternalLinkContext} from '#external-links';

export default {
  extraDependencies: ['html', 'language', 'to'],

  data: (url) => ({url}),

  slots: {
    context: {
      validate: () => isExternalLinkContext,
      default: 'generic',
    },
  },

  generate: (data, slots, {html, language, to}) =>
    html.tag('span', {class: 'external-icon'},
      html.tag('svg',
        html.tag('use', {
          href:
            to('staticMisc.icon',
              language.formatExternalLink(data.url, {
                style: 'icon-id',
                context: slots.context,
              })),
        }))),
};