diff options
Diffstat (limited to 'src/content/dependencies/generateGroupNavAccent.js')
-rw-r--r-- | src/content/dependencies/generateGroupNavAccent.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/content/dependencies/generateGroupNavAccent.js b/src/content/dependencies/generateGroupNavAccent.js new file mode 100644 index 00000000..0e4ebe8a --- /dev/null +++ b/src/content/dependencies/generateGroupNavAccent.js @@ -0,0 +1,53 @@ +import {empty} from '#sugar'; + +export default { + contentDependencies: [ + 'generateInterpageDotSwitcher', + 'linkGroup', + 'linkGroupGallery', + ], + + extraDependencies: ['html', 'language'], + + relations: (relation, group) => ({ + switcher: + relation('generateInterpageDotSwitcher'), + + infoLink: + relation('linkGroup', group), + + galleryLink: + (empty(group.albums) + ? null + : relation('linkGroupGallery', group)), + }), + + slots: { + currentExtra: { + validate: v => v.is('gallery'), + }, + }, + + generate: (relations, slots, {language}) => + relations.switcher.slots({ + links: [ + relations.infoLink.slots({ + attributes: [ + slots.currentExtra === null && + {class: 'current'}, + ], + + content: language.$('misc.nav.info'), + }), + + relations.galleryLink?.slots({ + attributes: [ + slots.currentExtra === 'gallery' && + {class: 'current'}, + ], + + content: language.$('misc.nav.gallery'), + }), + ], + }), +}; |