From 978c10394cacfea79982e2f0d4c0842cccd766bd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 6 Feb 2021 12:59:56 -0400 Subject: let homepage rows specify their own theme color --- upd8.js | 58 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/upd8.js b/upd8.js index 3bd5997f..5ff1a8b6 100755 --- a/upd8.js +++ b/upd8.js @@ -1221,6 +1221,8 @@ async function processHomepageInfoFile(file) { return {error: 'Expected "Row" (name) field!'}; } + const color = getBasicField(section, 'Color'); + const type = getBasicField(section, 'Type'); if (!type) { return {error: 'Expected "Type" field!'}; @@ -1230,6 +1232,8 @@ async function processHomepageInfoFile(file) { return {error: `Expected "Type" field to be one of: ${validRowTypes.join(', ')}`}; } + const row = {name, color, type}; + switch (type) { case 'albums': { const group = getBasicField(section, 'Group') || null; @@ -1257,7 +1261,7 @@ async function processHomepageInfoFile(file) { return {error: 'Expected every action to be a -type link!'}; } - return {name, type, group, groupCount, albums, actions}; + return {...row, group, groupCount, albums, actions}; } } }); @@ -1770,31 +1774,33 @@ async function writeHomepage() { content: fixWS`

${wikiInfo.name}

${homepageInfo.rows.map((row, i) => fixWS` -

${row.name}

- ${row.type === 'albums' && fixWS` -
- ${getAlbumGridHTML({ - entries: ( - row.group === 'new-releases' ? getNewReleases(row.groupCount) : - ((getLinkedGroup(row.group)?.albums || []) - .slice() - .reverse() - .slice(0, row.groupCount) - .map(album => ({item: album}))) - ).concat(row.albums - .map(getLinkedAlbum) - .map(album => ({item: album})) - ), - lazy: i > 0 - })} - ${row.actions.length && fixWS` -
- ${row.actions.map(action => action - .replace(' - `} -
- `} +
+

${row.name}

+ ${row.type === 'albums' && fixWS` +
+ ${getAlbumGridHTML({ + entries: ( + row.group === 'new-releases' ? getNewReleases(row.groupCount) : + ((getLinkedGroup(row.group)?.albums || []) + .slice() + .reverse() + .slice(0, row.groupCount) + .map(album => ({item: album}))) + ).concat(row.albums + .map(getLinkedAlbum) + .map(album => ({item: album})) + ), + lazy: i > 0 + })} + ${row.actions.length && fixWS` +
+ ${row.actions.map(action => action + .replace(' + `} +
+ `} +
`).join('\n')} ` }, -- cgit 1.3.0-6-gf8a5