diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-07-25 16:35:02 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-13 22:54:14 -0300 |
commit | 48dde4a388fd4c31dd5680f7535419874124e554 (patch) | |
tree | 50c0fce8ef19f3bae856e79b1dc92e257e0db4ab /src/content/dependencies/generateLyricsSwitcher.js | |
parent | b1ff1444c47f6bd8c532e3a76eb2a5b92ed82a0e (diff) |
wip
Diffstat (limited to 'src/content/dependencies/generateLyricsSwitcher.js')
-rw-r--r-- | src/content/dependencies/generateLyricsSwitcher.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/content/dependencies/generateLyricsSwitcher.js b/src/content/dependencies/generateLyricsSwitcher.js new file mode 100644 index 00000000..1c9ee6a3 --- /dev/null +++ b/src/content/dependencies/generateLyricsSwitcher.js @@ -0,0 +1,49 @@ +export default { + contentDependencies: ['transformContent'], + extraDependencies: ['html', 'language'], + + relations: (relation, entries) => ({ + annotations: + entries + .map(entry => entry.annotation) + .map(annotation => relation('transformContent', annotation)), + }), + + slots: { + tag: {type: 'string', default: 'p'}, + }, + + generate: (relations, slots, {html, language}) => + html.tag(slots.tag, {class: 'lyrics-switcher'}, + language.$('releaseInfo.lyrics.switcher', { + entries: + language.formatListWithoutSeparator( + relations.annotations + .map((annotation, index) => + html.tag('span', {[html.joinChildren]: ''}, [ + html.tag('a', + {href: '#'}, + + index === 0 && + {style: 'display: none'}, + + annotation + .slots({ + mode: 'inline', + textOnly: true, + })), + + html.tag('a', + {class: 'current'}, + + index >= 1 && + {style: 'display: none'}, + + annotation + .slots({ + mode: 'inline', + textOnly: true, + })), + ]))), + })), +}; |