« get me outta code hell

extract actual file IO functions - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write/page-template.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-01-07 21:08:08 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-01-07 21:08:08 -0400
commit078b9656fe16738967943e4ca94866481f4f1d21 (patch)
tree4a040964cf53ee10c5bf51c797b52bb80a7b5f99 /src/write/page-template.js
parent1ced8788ca64ed430fac003dc9281f7194193956 (diff)
extract actual file IO functions
Diffstat (limited to 'src/write/page-template.js')
-rw-r--r--src/write/page-template.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/write/page-template.js b/src/write/page-template.js
index 61579549..f7faeed0 100644
--- a/src/write/page-template.js
+++ b/src/write/page-template.js
@@ -606,3 +606,24 @@ export function generateRedirectHTML(title, target, {
       ])),
   ]);
 }
+
+export function generateGlobalWikiDataJSON({
+  serializeThings,
+  wikiData,
+}) {
+  return '{\n' +
+    ([
+      `"albumData": ${stringifyThings(wikiData.albumData)},`,
+      wikiData.wikiInfo.enableFlashesAndGames &&
+        `"flashData": ${stringifyThings(wikiData.flashData)},`,
+      `"artistData": ${stringifyThings(wikiData.artistData)}`,
+    ]
+      .filter(Boolean)
+      .map(line => '  ' + line)
+      .join('\n')) +
+    '\n}';
+
+  function stringifyThings(thingData) {
+    return JSON.stringify(serializeThings(thingData));
+  }
+}