« get me outta code hell

let homepage rows specify their own theme color - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-02-06 12:59:56 -0400
committer(quasar) nebula <towerofnix@gmail.com>2021-02-06 12:59:56 -0400
commit978c10394cacfea79982e2f0d4c0842cccd766bd (patch)
tree5e173acc62bad09cf8720fc8fd2414f8c43c8f00
parent8b5aab7d13599ff8aae09ac3792041e3594c3b80 (diff)
let homepage rows specify their own theme color
-rwxr-xr-xupd8.js58
1 files 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 <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`
                 <h1>${wikiInfo.name}</h1>
                 ${homepageInfo.rows.map((row, i) => fixWS`
-                    <h2>${row.name}</h2>
-                    ${row.type === 'albums' && fixWS`
-                        <div class="grid-listing">
-                            ${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`
-                                <div class="grid-actions">
-                                    ${row.actions.map(action => action
-                                        .replace('<a', '<a class="box grid-item"')).join('\n')}
-                                </div>
-                            `}
-                        </div>
-                    `}
+                    <section class="row" style="${getLinkThemeString(row)}">
+                        <h2>${row.name}</h2>
+                        ${row.type === 'albums' && fixWS`
+                            <div class="grid-listing">
+                                ${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`
+                                    <div class="grid-actions">
+                                        ${row.actions.map(action => action
+                                            .replace('<a', '<a class="box grid-item"')).join('\n')}
+                                    </div>
+                                `}
+                            </div>
+                        `}
+                    </section>
                 `).join('\n')}
             `
         },