« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/page/homepage.js95
-rw-r--r--src/static/site3.css14
-rw-r--r--src/write/page-template.js2
3 files changed, 50 insertions, 61 deletions
diff --git a/src/page/homepage.js b/src/page/homepage.js
index 465152aa..d65b2ba7 100644
--- a/src/page/homepage.js
+++ b/src/page/homepage.js
@@ -141,63 +141,50 @@ export function writeTargetless({wikiData}) {
         ],
       },
 
-      sidebarLeft: homepageLayout.sidebarContent && {
-        wide: true,
+      sidebarLeft: {
         collapse: false,
+        wide: true,
         stickyMode: 'none',
-        // This is a pretty filthy hack! 8ut otherwise, the [[news]] part
-        // gets treated like it's a reference to the track named "news",
-        // which o8viously isn't what we're going for. Gotta catch that
-        // 8efore we pass it to transformMultiline, 'cuz otherwise it'll
-        // get repl8ced with just the word "news" (or anything else that
-        // transformMultiline does with references it can't match) -- and
-        // we can't match that for replacing it with the news column!
-        //
-        // And no, I will not make [[news]] into part of transformMultiline
-        // (even though that would 8e hilarious).
-        content:
-          transformMultiline(
-            homepageLayout.sidebarContent
-              .replace('[[news]]', '__GENERATE_NEWS__'),
-            {
+
+        multiple: [
+          homepageLayout.sidebarContent &&
+            transformMultiline(homepageLayout.sidebarContent, {
               thumb: 'medium',
-            })
-            .replace('<p>__GENERATE_NEWS__</p>',
-              wikiInfo.enableNews
-                ? [
-                    html.tag('h1',
-                      language.$('homepage.news.title')),
-
-                    ...newsData
-                      .slice(0, 3)
-                      .map((entry, i) =>
-                        html.tag('article',
-                          {
-                            class: [
-                              'news-entry',
-                              i === 0 && 'first-news-entry',
-                            ],
-                          },
-                          [
-                            html.tag('h2', [
-                              html.tag('time',
-                                language.formatDate(entry.date)),
-                              link.newsEntry(entry),
-                            ]),
-
-                            transformMultiline(entry.contentShort, {
-                              thumb: 'medium',
-                            }),
-
-                            entry.contentShort !== entry.content &&
-                              link.newsEntry(entry, {
-                                text: language.$('homepage.news.entry.viewRest')
-                              }),
-                          ])),
-                  ].join('\n')
-                : html.tag('p',
-                    html.tag('i',
-                      `News requested in content description but this feature isn't enabled`))),
+            }),
+
+          wikiInfo.enableNews &&
+            [
+              html.tag('h1',
+                language.$('homepage.news.title')),
+
+              ...newsData
+                .slice(0, 3)
+                .map((entry, i) =>
+                  html.tag('article',
+                    {
+                      class: [
+                        'news-entry',
+                        i === 0 && 'first-news-entry',
+                      ],
+                    },
+                    [
+                      html.tag('h2', [
+                        html.tag('time',
+                          language.formatDate(entry.date)),
+                        link.newsEntry(entry),
+                      ]),
+
+                      transformMultiline(entry.contentShort, {
+                        thumb: 'medium',
+                      }),
+
+                      entry.contentShort !== entry.content &&
+                        link.newsEntry(entry, {
+                          text: language.$('homepage.news.entry.viewRest')
+                        }),
+                    ])),
+            ],
+        ],
       },
 
       nav: {
diff --git a/src/static/site3.css b/src/static/site3.css
index bdb2623b..05d1f75d 100644
--- a/src/static/site3.css
+++ b/src/static/site3.css
@@ -135,6 +135,13 @@ body::before {
   align-self: flex-start;
 }
 
+.sidebar-column.wide {
+  max-width: 350px;
+  flex-basis: 300px;
+  flex-shrink: 0;
+  flex-grow: 1;
+}
+
 .sidebar-multiple {
   display: flex;
   flex-direction: column;
@@ -157,13 +164,6 @@ body::before {
   margin-left: 10px;
 }
 
-.sidebar.wide {
-  max-width: 350px;
-  flex-basis: 300px;
-  flex-shrink: 0;
-  flex-grow: 1;
-}
-
 #content {
   position: relative;
   --content-padding: 20px;
diff --git a/src/write/page-template.js b/src/write/page-template.js
index e0b37d49..663c1d90 100644
--- a/src/write/page-template.js
+++ b/src/write/page-template.js
@@ -242,6 +242,7 @@ export function generateDocumentHTML(pageInfo, {
       : multiple
       ? html.tag('div',
           {
+            [html.onlyIfContent]: true,
             id,
             class: [
               'sidebar-column',
@@ -252,6 +253,7 @@ export function generateDocumentHTML(pageInfo, {
             ],
           },
           multiple
+            .filter(Boolean)
             .map((infoOrContent) =>
               (typeof infoOrContent === 'object' && !Array.isArray(infoOrContent))
                 ? infoOrContent