From 453ce8b4c56262d7271921e6febc4a7f535d4bec Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 13 Apr 2024 08:16:17 -0300 Subject: content: generatePageLayout: don't stringify mainContent twice --- src/content/dependencies/generatePageLayout.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') 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}) => -- cgit 1.3.0-6-gf8a5