« get me outta code hell

more sticky heading adjustments - 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>2022-12-07 07:30:48 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-12-07 07:30:48 -0400
commitf18ddd61d7430f82116b7f6003e68a548f39f766 (patch)
treea424f5145b759b765eff22498019a5b16e79272a /src
parent0735a45e0ddf693e35202c7c3ef3c15886139843 (diff)
more sticky heading adjustments
Diffstat (limited to 'src')
-rw-r--r--src/misc-templates.js6
-rw-r--r--src/page/static.js18
-rw-r--r--src/static/client.js10
-rwxr-xr-xsrc/upd8.js5
4 files changed, 29 insertions, 10 deletions
diff --git a/src/misc-templates.js b/src/misc-templates.js
index 10422a29..d7b24fbd 100644
--- a/src/misc-templates.js
+++ b/src/misc-templates.js
@@ -727,13 +727,17 @@ function unbound_generateStickyHeadingContainer({
   html,
   img,
 
+  class: classes,
   coverSrc,
   coverAlt,
   coverTags,
   title,
 }) {
   return html.tag('div',
-    {class: 'content-sticky-heading-container'},
+    {class: [
+      'content-sticky-heading-container',
+      coverSrc && 'has-cover',
+    ].concat(classes)},
     [
       html.tag('div', {class: 'content-sticky-heading-row'}, [
         html.tag('h1', title),
diff --git a/src/page/static.js b/src/page/static.js
index 2a0f5e53..1689d16b 100644
--- a/src/page/static.js
+++ b/src/page/static.js
@@ -10,15 +10,23 @@ export function write(staticPage) {
   const page = {
     type: 'page',
     path: ['staticPage', staticPage.directory],
-    page: ({html, transformMultiline}) => ({
+    page: ({
+      generateStickyHeadingContainer,
+      html,
+      transformMultiline,
+    }) => ({
       title: staticPage.name,
       stylesheet: staticPage.stylesheet,
 
       main: {
-        content: html.tag('div', {class: 'long-content'}, [
-          html.tag('h1', staticPage.name),
-          transformMultiline(staticPage.content),
-        ]),
+        content: [
+          generateStickyHeadingContainer({
+            class: ['long-content'],
+            title: staticPage.name,
+          }),
+          html.tag('div', {class: 'long-content'},
+            transformMultiline(staticPage.content)),
+        ],
       },
 
       nav: {simple: true},
diff --git a/src/static/client.js b/src/static/client.js
index dcb39226..15f21fdb 100644
--- a/src/static/client.js
+++ b/src/static/client.js
@@ -487,10 +487,12 @@ function updateStickyHeading() {
   } of stickyHeadingInfo) {
     let closestHeading = null;
 
-    if (contentCover.getBoundingClientRect().bottom < 0) {
-      stickyCoverContainer.classList.add('visible');
-    } else {
-      stickyCoverContainer.classList.remove('visible');
+    if (contentCover && stickyCoverContainer) {
+      if (contentCover.getBoundingClientRect().bottom < 0) {
+        stickyCoverContainer.classList.add('visible');
+      } else {
+        stickyCoverContainer.classList.remove('visible');
+      }
     }
 
     if (topOfViewInside(contentContainer)) {
diff --git a/src/upd8.js b/src/upd8.js
index bc574c62..f7abdcb8 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -562,6 +562,11 @@ function transformMultiline(text, {parseAttributes, transformInline}) {
       ) {
         lineTag = '';
       }
+
+      // for sticky headings!
+      if (elementMatch) {
+        lineContent = lineContent.replace(/<h2/, `<h2 class="content-heading"`)
+      }
     }
 
     let pushString = indentString.repeat(indentThisLine);