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 ++++++++++++++++++++-------------------------- src/static/site3.css | 14 +++---- src/write/page-template.js | 2 + 3 files changed, 50 insertions(+), 61 deletions(-) (limited to 'src') 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: { diff --git a/src/static/site3.css b/src/static/site3.css index bdb2623..05d1f75 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 e0b37d4..663c1d9 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 -- cgit 1.3.0-6-gf8a5