« get me outta code hell

content: generateNewsEntryPage - 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-08-01 11:08:53 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-01 11:09:24 -0300
commite03756a5113f9b9b37588dfa7ddfa96137c685fe (patch)
tree1ed79db32e9e4a3a558048618d76bbb3406dc713 /src/page
parentef873ddd0296b45a3a330c1ba447d0b3ba417ca0 (diff)
content: generateNewsEntryPage
Diffstat (limited to 'src/page')
-rw-r--r--src/page/index.js2
-rw-r--r--src/page/news.js141
2 files changed, 19 insertions, 124 deletions
diff --git a/src/page/index.js b/src/page/index.js
index 408a7e72..a2cdbbdf 100644
--- a/src/page/index.js
+++ b/src/page/index.js
@@ -14,7 +14,7 @@ export * as artistAlias from './artist-alias.js';
 export * as group from './group.js';
 export * as homepage from './homepage.js';
 export * as listing from './listing.js';
-// export * as news from './news.js';
+export * as news from './news.js';
 export * as static from './static.js';
 export * as tag from './tag.js';
 export * as track from './track.js';
diff --git a/src/page/news.js b/src/page/news.js
index 00d1e4dc..4928a116 100644
--- a/src/page/news.js
+++ b/src/page/news.js
@@ -10,130 +10,25 @@ export function targets({wikiData}) {
   return wikiData.newsData;
 }
 
-export function write(entry, {wikiData}) {
-  const page = {
-    type: 'page',
-    path: ['newsEntry', entry.directory],
-    page: ({
-      generateNavigationLinks,
-      html,
-      language,
-      link,
-      transformMultiline,
-    }) => ({
-      title: language.$('newsEntryPage.title', {entry: entry.name}),
-
-      main: {
-        classes: ['long-content'],
-        headingMode: 'sticky',
-
-        content: [
-          html.tag('p',
-            language.$('newsEntryPage.published', {
-              date: language.formatDate(entry.date),
-            })),
-
-          transformMultiline(entry.content),
-        ],
-      },
-
-      nav: generateNewsEntryNav(entry, {
-        generateNavigationLinks,
-        html,
-        language,
-        link,
-        wikiData,
-      }),
-    }),
-  };
-
-  return [page];
-}
-
-export function writeTargetless({wikiData}) {
-  const {newsData} = wikiData;
-
-  const page = {
-    type: 'page',
-    path: ['newsIndex'],
-    page: ({
-      html,
-      language,
-      link,
-      transformMultiline,
-    }) => ({
-      title: language.$('newsIndex.title'),
-
-      main: {
-        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'
-                      ),
-                    })),
-              ])),
+export function pathsForTarget(newsEntry) {
+  return [
+    {
+      type: 'page',
+      path: ['newsEntry', newsEntry.directory],
+      contentFunction: {
+        name: 'generateNewsEntryPage',
+        args: [newsEntry],
       },
-
-      nav: {simple: true},
-    }),
-  };
-
-  return [page];
+    },
+  ];
 }
 
-function generateNewsEntryNav(entry, {
-  generateNavigationLinks,
-  html,
-  language,
-  link,
-  wikiData: {newsData},
-}) {
-  // The newsData list is sorted reverse chronologically (newest ones first),
-  // so the way we find next/previous entries is flipped from normal.
-  const previousNextLinks = generateNavigationLinks(entry, {
-    data: newsData.slice().reverse(),
-    linkKey: 'newsEntry',
-
-    html,
-    language,
-    link,
-  });
-
-  return {
-    linkContainerClasses: ['nav-links-hierarchy'],
-    links: [
-      {toHome: true},
-      {
-        path: ['localized.newsIndex'],
-        title: language.$('newsEntryPage.nav.news'),
-      },
-      {
-        html: language.$('newsEntryPage.nav.entry', {
-          date: language.formatDate(entry.date),
-          entry: link.newsEntry(entry, {class: 'current'}),
-        }),
-      },
-      previousNextLinks && {
-        divider: false,
-        html: `(${previousNextLinks})`,
-      },
-    ],
-  };
+export function pathsTargetless() {
+  return [
+    {
+      type: 'page',
+      path: ['newsIndex'],
+      contentFunction: {name: 'generateNewsIndexPage'},
+    },
+  ];
 }