« get me outta code hell

content, css: generatePageLayout: subtitle slot - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-17 14:19:33 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-11-17 16:35:08 -0400
commit36dd9637dcdd62ae16dec31c9325b439d11a95e4 (patch)
treeb20fa17242e19a596423717f18a9321ed4291563 /src/content/dependencies
parente6aa957cc3bde791c3e0ee0e05dbf4fad0438481 (diff)
content, css: generatePageLayout: subtitle slot
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generatePageLayout.js42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js
index 460ae51a..cc8bc777 100644
--- a/src/content/dependencies/generatePageLayout.js
+++ b/src/content/dependencies/generatePageLayout.js
@@ -74,6 +74,11 @@ export default {
       default: true,
     },
 
+    subtitle: {
+      type: 'html',
+      mutable: false,
+    },
+
     showSearch: {
       type: 'boolean',
       default: true,
@@ -268,6 +273,14 @@ export default {
           })
         : html.tag('h1', titleContentsHTML));
 
+    // TODO: There could be neat interactions with the sticky heading here,
+    // but for now subtitle is totally separate.
+    const subtitleHTML =
+      (html.isBlank(slots.subtitle)
+        ? null
+        : html.tag('h2', {class: 'page-subtitle'},
+            language.sanitize(slots.subtitle)));
+
     let footerContent = slots.footerContent;
 
     if (html.isBlank(footerContent) && relations.defaultFooterContent) {
@@ -282,8 +295,12 @@ export default {
       html.tag('main', {id: 'content'},
         {class: slots.mainClasses},
 
+        !html.isBlank(subtitleHTML) &&
+          {class: 'has-subtitle'},
+
         [
           titleHTML,
+          subtitleHTML,
 
           html.tag('div', {id: 'cover-art-container'},
             {[html.onlyIfContent]: true},
@@ -604,14 +621,23 @@ export default {
 
           html.tag('head', [
             html.tag('title',
-              (slots.showWikiNameInTitle
-                ? language.formatString('misc.pageTitle.withWikiName', {
-                    title: slots.title,
-                    wikiName: data.wikiName,
-                  })
-                : language.formatString('misc.pageTitle', {
-                    title: slots.title,
-                  }))),
+              language.encapsulate('misc.pageTitle', workingCapsule => {
+                const workingOptions = {};
+
+                workingOptions.title = slots.title;
+
+                if (!html.isBlank(slots.subtitle)) {
+                  workingCapsule += '.withSubtitle';
+                  workingOptions.subtitle = slots.subtitle;
+                }
+
+                if (slots.showWikiNameInTitle) {
+                  workingCapsule += '.withWikiName';
+                  workingOptions.wikiName = data.wikiName;
+                }
+
+                return language.$(workingCapsule, workingOptions);
+              })),
 
             html.tag('meta', {charset: 'utf-8'}),
             html.tag('meta', {