« get me outta code hell

module-ify static pages - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-06-04 15:19:03 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-06-04 15:19:03 -0300
commit635eea4460bb635766bcf9d0a666b7d5ddb2dba3 (patch)
tree18a1ce8547a560ac83c79a8d8437f4b105a6d3f1 /src
parent6f2f61c1330dbd48a1fdbc564a0fec50a59f2d88 (diff)
module-ify static pages
Diffstat (limited to 'src')
-rw-r--r--src/page/index.js1
-rw-r--r--src/page/static.js40
-rwxr-xr-xsrc/upd8.js32
3 files changed, 41 insertions, 32 deletions
diff --git a/src/page/index.js b/src/page/index.js
index 384b4193..42204947 100644
--- a/src/page/index.js
+++ b/src/page/index.js
@@ -43,5 +43,6 @@ export * as album from './album.js';
 export * as artist from './artist.js';
 export * as artistAlias from './artist-alias.js';
 export * as group from './group.js';
+export * as static from './static.js';
 export * as news from './news.js';
 export * as track from './track.js';
diff --git a/src/page/static.js b/src/page/static.js
new file mode 100644
index 00000000..ff57c4fb
--- /dev/null
+++ b/src/page/static.js
@@ -0,0 +1,40 @@
+// Static content page specification. (These are static pages coded into the
+// wiki data folder, used for a variety of purposes, e.g. wiki info,
+// changelog, and so on.)
+
+// Imports
+
+import fixWS from 'fix-whitespace';
+
+// Page exports
+
+export function targets({wikiData}) {
+    return wikiData.staticPageData;
+}
+
+export function write(staticPage, {wikiData}) {
+    const page = {
+        type: 'page',
+        path: ['staticPage', staticPage.directory],
+        page: ({
+            strings,
+            transformMultiline
+        }) => ({
+            title: staticPage.name,
+            stylesheet: staticPage.stylesheet,
+
+            main: {
+                content: fixWS`
+                    <div class="long-content">
+                        <h1>${staticPage.name}</h1>
+                        ${transformMultiline(staticPage.content)}
+                    </div>
+                `
+            },
+
+            nav: {simple: true}
+        })
+    };
+
+    return [page];
+}
diff --git a/src/upd8.js b/src/upd8.js
index b9fa0274..a1fafb27 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -2429,38 +2429,6 @@ function writeMiscellaneousPages({wikiData}) {
     ];
 }
 
-function writeStaticPages({wikiData}) {
-    return wikiData.staticPageData.map(staticPage => writeStaticPage(staticPage, {wikiData}));
-}
-
-function writeStaticPage(staticPage, {wikiData}) {
-    const page = {
-        type: 'page',
-        path: ['staticPage', staticPage.directory],
-        page: ({
-            strings,
-            transformMultiline
-        }) => ({
-            title: staticPage.name,
-            stylesheet: staticPage.stylesheet,
-
-            main: {
-                content: fixWS`
-                    <div class="long-content">
-                        <h1>${staticPage.name}</h1>
-                        ${transformMultiline(staticPage.content)}
-                    </div>
-                `
-            },
-
-            nav: {simple: true}
-        })
-    };
-
-    return [page];
-}
-
-
 function getRevealStringFromWarnings(warnings, {strings}) {
     return strings('misc.contentWarnings', {warnings}) + `<br><span class="reveal-interaction">${strings('misc.contentWarnings.reveal')}</span>`
 }