From 55b16f303f23e286dfdf33e5d84fe3981f643746 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 1 Mar 2023 23:35:56 -0400 Subject: remove [[news]] hack, auto-add news sidebar --- src/page/homepage.js | 95 +++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 54 deletions(-) (limited to 'src/page') diff --git a/src/page/homepage.js b/src/page/homepage.js index 465152a..d65b2ba 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('

__GENERATE_NEWS__

', - 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: { -- cgit 1.3.0-6-gf8a5