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
27
28
|
import {isExternalLinkContext} from '#external-links';
export default {
extraDependencies: ['html', 'language', 'to'],
data: (url) => ({url}),
slots: {
context: {
// This awkward syntax is because the slot descriptor validator can't
// differentiate between a function that returns a validator (the usual
// syntax) and a function that is itself a validator.
validate: () => isExternalLinkContext,
default: 'generic',
},
},
generate: (data, slots, {html, language, to}) =>
html.tag('svg',
html.tag('use', {
href:
to('staticMisc.icon',
language.formatExternalLink(data.url, {
style: 'icon-id',
context: slots.context,
})),
})),
};
|