« get me outta code hell

content: generatePageLayout: don't stringify mainContent twice - 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 <qznebula@protonmail.com>2024-04-13 08:16:17 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-13 08:16:31 -0300
commit453ce8b4c56262d7271921e6febc4a7f535d4bec (patch)
treee9bba2b43518cc8e7d066bf500cc87b01d4526f2 /src
parent0a5a1e3452e7f895d1b2abf3f726e5e4735f79aa (diff)
content: generatePageLayout: don't stringify mainContent twice
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generatePageLayout.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js
index 313ca9a..cbfc905 100644
--- a/src/content/dependencies/generatePageLayout.js
+++ b/src/content/dependencies/generatePageLayout.js
@@ -219,6 +219,14 @@ export default {
     const colors = getColors(slots.color ?? data.wikiColor);
     const hasSocialEmbed = !html.isBlank(slots.socialEmbed);
 
+    // Hilariously jank. Sorry! We're going to need this content later ANYWAY,
+    // so it's "fine" to stringify it here, but this DOES mean that we're
+    // stringifying (and resolving) the content without the context that it's
+    // e.g. going to end up in a page HTML hierarchy. Might have implications
+    // later, mainly for: https://github.com/hsmusic/hsmusic-wiki/issues/434
+    const mainContentHTML = html.tags([slots.mainContent]).toString();
+    const hasID = id => mainContentHTML.includes(`id="${id}"`);
+
     const titleContentsHTML =
       (html.isBlank(slots.title)
         ? null
@@ -264,7 +272,7 @@ export default {
 
           html.tag('div', {class: 'main-content-container'},
             {[html.onlyIfContent]: true},
-            slots.mainContent),
+            mainContentHTML),
         ]);
 
     const footerHTML =
@@ -393,12 +401,6 @@ export default {
         ? rightSidebar.getSlotValue('collapse')
         : true);
 
-    const hasID = (() => {
-      // Hilariously jank. Sorry!
-      const mainContentHTML = slots.mainContent.toString();
-      return id => mainContentHTML.includes(`id="${id}"`);
-    })();
-
     const processSkippers = skipperList =>
       skipperList
         .filter(({condition, id}) =>