diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-07-07 12:28:40 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-07-07 12:39:14 -0300 |
commit | fbbafa606f12b0ecf3ac89918b424f0ec4a8de4e (patch) | |
tree | 58b1b4c4adc9ac5e9bbe7d2b85becd61c5dd4d41 /src/content | |
parent | 556eda40caf7f3921507d90afc81073bb74fbd43 (diff) |
content: listGroupsByName, listing feature flags
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/dependencies/generateListingIndexList.js | 7 | ||||
-rw-r--r-- | src/content/dependencies/listGroupsByName.js | 49 |
2 files changed, 53 insertions, 3 deletions
diff --git a/src/content/dependencies/generateListingIndexList.js b/src/content/dependencies/generateListingIndexList.js index 32125955..e4a2f5c7 100644 --- a/src/content/dependencies/generateListingIndexList.js +++ b/src/content/dependencies/generateListingIndexList.js @@ -14,9 +14,10 @@ export default { const targetListings = sprawl.listingTargetSpec .map(({listings}) => - listings.filter(({condition: c}) => - !c || - c({wikiData: {wikiInfo: sprawl.wikiInfo}}))); + listings + .filter(listing => + !listing.featureFlag || + sprawl.wikiInfo[listing.featureFlag])); query.wikiColor = sprawl.wikiInfo.color; diff --git a/src/content/dependencies/listGroupsByName.js b/src/content/dependencies/listGroupsByName.js new file mode 100644 index 00000000..df35937b --- /dev/null +++ b/src/content/dependencies/listGroupsByName.js @@ -0,0 +1,49 @@ +import {stitchArrays} from '../../util/sugar.js'; +import {sortAlphabetically} from '../../util/wiki-data.js'; + +export default { + contentDependencies: ['generateListingPage', 'linkGroup', 'linkGroupGallery'], + extraDependencies: ['language', 'wikiData'], + + sprawl({groupData}) { + return {groupData}; + }, + + query({groupData}, spec) { + return { + spec, + + groups: sortAlphabetically(groupData.slice()), + }; + }, + + relations(relation, query) { + return { + page: relation('generateListingPage', query.spec), + + infoLinks: + query.groups + .map(group => relation('linkGroup', group)), + + galleryLinks: + query.groups + .map(group => relation('linkGroupGallery', group)), + }; + }, + + generate(relations, {language}) { + return relations.page.slots({ + type: 'rows', + rows: + stitchArrays({ + infoLink: relations.infoLinks, + galleryLink: relations.galleryLinks, + }).map(({infoLink, galleryLink}) => ({ + group: infoLink, + gallery: + galleryLink + .slot('content', language.$('listingPage.listGroups.byName.item.gallery')), + })), + }); + }, +}; |