Skip to content

Commit

Permalink
fix(prebuild-generate-static-collection-menus): skip excluded collect…
Browse files Browse the repository at this point in the history
…ions

Generate static collection menus prebuild script: skip collections that are not included according to the config.
  • Loading branch information
SebastianKohler authored Aug 28, 2024
1 parent 91729cd commit 6a5a339
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this

## [Unreleased]

### Fixed

- Generate static collection menus prebuild script: skip collections that are not included according to the config.



## [1.5.0] – 2024-08-28
Expand Down
10 changes: 7 additions & 3 deletions prebuild-generate-static-collection-menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,30 @@ async function generateStaticCollectionMenus() {
if (multilingualCollectionTOC) {
collectionsEndpoint += '/' + locale;
}

const collections = await common.fetchFromAPI(collectionsEndpoint);
const includedCollections = config.collections.order.flat();

if (collections) {
// Loop through all collections
for (let i = 0; i < collections.length; i++) {
const collectionId = collections[i]['id'] || 0;
const collectionTitle = collections[i]['title'] || '';

if (!collectionId) {
break;
if (!collectionId || !includedCollections.includes(collectionId)) {
continue;
}

// Get collection TOC
let tocEndpoint = APIBase + '/toc/' + collectionId;
if (multilingualCollectionTOC) {
tocEndpoint += '/' + locale;
}

const tocJSON = await common.fetchFromAPI(tocEndpoint);

if (tocJSON == null) {
console.log('Unable to fetch TOC for collection ', collectionId);
console.log('Error: unable to fetch TOC for collection ', collectionId);
break;
}

Expand Down

0 comments on commit 6a5a339

Please sign in to comment.