« get me outta code hell

remove [[news]] hack, auto-add news sidebar - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-03-01 23:35:56 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-03-01 23:35:56 -0400
commit55b16f303f23e286dfdf33e5d84fe3981f643746 (patch)
tree7aa33df6c54e84cebaa81baee2b12db09db17413 /src/page
parent8b9e855c57c8879934f9ccc8fa17f73966465a17 (diff)
remove [[news]] hack, auto-add news sidebar
Diffstat (limited to 'src/page')
-rw-r--r--src/page/homepage.js95
1 files changed, 41 insertions, 54 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: {