From 7c5939aefafc88201eb73ba67a35d4de77c94d7a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 19 Oct 2024 21:46:14 -0300 Subject: content: generateGroupNavAccent (dots) --- src/content/dependencies/generateGroupNavLinks.js | 131 +++++++--------------- 1 file changed, 43 insertions(+), 88 deletions(-) (limited to 'src/content/dependencies/generateGroupNavLinks.js') diff --git a/src/content/dependencies/generateGroupNavLinks.js b/src/content/dependencies/generateGroupNavLinks.js index 5cde2ab4..bdc3ee4c 100644 --- a/src/content/dependencies/generateGroupNavLinks.js +++ b/src/content/dependencies/generateGroupNavLinks.js @@ -1,48 +1,25 @@ -import {empty} from '#sugar'; - export default { - contentDependencies: [ - 'linkGroup', - 'linkGroupGallery', - ], - + contentDependencies: ['generateGroupNavAccent', 'linkGroup'], extraDependencies: ['html', 'language', 'wikiData'], - sprawl({groupCategoryData, wikiInfo}) { - return { - groupCategoryData, - enableGroupUI: wikiInfo.enableGroupUI, - enableListings: wikiInfo.enableListings, - }; - }, - - relations(relation, sprawl, group) { - if (!sprawl.enableGroupUI) { - return {}; - } - - const relations = {}; + sprawl: ({groupCategoryData, wikiInfo}) => ({ + groupCategoryData, + enableGroupUI: wikiInfo.enableGroupUI, + enableListings: wikiInfo.enableListings, + }), - relations.mainLink = - relation('linkGroup', group); + relations: (relation, _sprawl, group) => ({ + mainLink: + relation('linkGroup', group), - relations.infoLink = - relation('linkGroup', group); + accent: + relation('generateGroupNavAccent', group), + }), - if (!empty(group.albums)) { - relations.galleryLink = - relation('linkGroupGallery', group); - } - - return relations; - }, - - data(sprawl) { - return { - enableGroupUI: sprawl.enableGroupUI, - enableListings: sprawl.enableListings, - }; - }, + data: (sprawl, _group) => ({ + enableGroupUI: sprawl.enableGroupUI, + enableListings: sprawl.enableListings, + }), slots: { showExtraLinks: {type: 'boolean', default: false}, @@ -52,53 +29,31 @@ export default { }, }, - generate(data, relations, slots, {language}) { - if (!data.enableGroupUI) { - return [ - {auto: 'home'}, - {auto: 'current'}, - ]; - } - - const infoLink = - relations.infoLink.slots({ - attributes: {class: slots.currentExtra === null && 'current'}, - content: language.$('misc.nav.info'), - }); - - const extraLinks = [ - relations.galleryLink?.slots({ - attributes: {class: slots.currentExtra === 'gallery' && 'current'}, - content: language.$('misc.nav.gallery'), - }), - ]; - - const extrasPart = - (empty(extraLinks) - ? '' - : language.formatUnitList([infoLink, ...extraLinks])); - - const accent = - (extrasPart - ? `(${extrasPart})` - : null); - - return [ - {auto: 'home'}, - - data.enableListings && - { - path: ['localized.listingIndex'], - title: language.$('listingIndex.title'), - }, - - { - accent, - html: - language.$('groupPage.nav.group', { - group: relations.mainLink, - }), - }, - ].filter(Boolean); - }, + generate: (data, relations, slots, {language}) => + (data.enableGroupUI + ? [ + {auto: 'home'}, + + data.enableListings && + { + path: ['localized.listingIndex'], + title: language.$('listingIndex.title'), + }, + + { + html: + language.$('groupPage.nav.group', { + group: relations.mainLink, + }), + + accent: + relations.accent + .slot('currentExtra', slots.currentExtra), + }, + ].filter(Boolean) + + : [ + {auto: 'home'}, + {auto: 'current'}, + ]), }; -- cgit 1.3.0-6-gf8a5