« get me outta code hell

data-ize various page content calls - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page/news.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-01-25 14:51:00 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-01-25 14:51:00 -0400
commit76833c4083648d11780b0bbc9dd4de05479db240 (patch)
treee1832638c5219f244263bc0016de8f503bf64faa /src/page/news.js
parentcccebf04544d9d80e84a32a905c5c133a46badd4 (diff)
data-ize various page content calls
* page.cover replaces calls to generateCoverLink
* page.main.headingMode replaces calls to
  generateStickyHeadingContainer or html.tag('h1')
* page.main.classes: ['long-content'] replaces hard-
  coded calls to html.tag('div', {class: 'long-content'})
Diffstat (limited to 'src/page/news.js')
-rw-r--r--src/page/news.js81
1 files changed, 33 insertions, 48 deletions
diff --git a/src/page/news.js b/src/page/news.js
index 61a52dc..020b9a6 100644
--- a/src/page/news.js
+++ b/src/page/news.js
@@ -14,7 +14,6 @@ export function write(entry, {wikiData}) {
     path: ['newsEntry', entry.directory],
     page: ({
       generateNavigationLinks,
-      generateStickyHeadingContainer,
       html,
       language,
       link,
@@ -23,22 +22,16 @@ export function write(entry, {wikiData}) {
       title: language.$('newsEntryPage.title', {entry: entry.name}),
 
       main: {
+        classes: ['long-content'],
+        headingMode: 'sticky',
+
         content: [
-          generateStickyHeadingContainer({
-            class: ['long-content'],
-            title: language.$('newsEntryPage.title', {
-              entry: entry.name,
-            }),
-          }),
-
-          html.tag('div', {class: 'long-content'}, [
-            html.tag('p',
-              language.$('newsEntryPage.published', {
-                date: language.formatDate(entry.date),
-              })),
-
-            transformMultiline(entry.content),
-          ]),
+          html.tag('p',
+            language.$('newsEntryPage.published', {
+              date: language.formatDate(entry.date),
+            })),
+
+          transformMultiline(entry.content),
         ],
       },
 
@@ -62,7 +55,6 @@ export function writeTargetless({wikiData}) {
     type: 'page',
     path: ['newsIndex'],
     page: ({
-      generateStickyHeadingContainer,
       html,
       language,
       link,
@@ -71,37 +63,30 @@ export function writeTargetless({wikiData}) {
       title: language.$('newsIndex.title'),
 
       main: {
-        content: [
-          generateStickyHeadingContainer({
-            class: ['long-content'],
-            title: language.$('newsIndex.title'),
-          }),
-
-          html.tag('div',
-            {class: ['long-content', 'news-index']},
-            [
-              ...newsData.map(entry =>
-                html.tag('article',
-                  {id: entry.directory},
-                  [
-                    html.tag('h2', [
-                      html.tag('time',
-                        language.formatDate(entry.date)),
-                      link.newsEntry(entry),
-                    ]),
-
-                    transformMultiline(entry.contentShort),
-
-                    entry.contentShort !== entry.content &&
-                      html.tag('p',
-                        link.newsEntry(entry, {
-                          text: language.$(
-                            'newsIndex.entry.viewRest'
-                          ),
-                        })),
-                  ])),
-            ]),
-        ],
+        classes: ['long-content', 'news-index'],
+        headingMode: 'sticky',
+
+        content:
+          newsData.map(entry =>
+            html.tag('article',
+              {id: entry.directory},
+              [
+                html.tag('h2', [
+                  html.tag('time',
+                    language.formatDate(entry.date)),
+                  link.newsEntry(entry),
+                ]),
+
+                transformMultiline(entry.contentShort),
+
+                entry.contentShort !== entry.content &&
+                  html.tag('p',
+                    link.newsEntry(entry, {
+                      text: language.$(
+                        'newsIndex.entry.viewRest'
+                      ),
+                    })),
+              ])),
       },
 
       nav: {simple: true},