« get me outta code hell

content: generatePageLayout: drop legacy sidebar slots - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-03 18:20:08 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-03 18:21:07 -0300
commitbaeaa0f7a8f88bc56101337ae8f4443d21b089e3 (patch)
tree230e83aa31809754b201c84d19278c59ff87d70f /src/content
parent666375a0409155d23fc7b795210db1faaccd33a7 (diff)
content: generatePageLayout: drop legacy sidebar slots
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generatePageLayout.js91
1 files changed, 14 insertions, 77 deletions
diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js
index 318c8940..5866ac26 100644
--- a/src/content/dependencies/generatePageLayout.js
+++ b/src/content/dependencies/generatePageLayout.js
@@ -1,41 +1,10 @@
 import {openAggregate} from '#aggregate';
 import {empty} from '#sugar';
 
-function legacySidebarSlots(side) {
-  return {
-    [side + 'Content']: {
-      type: 'html',
-      mutable: false,
-    },
-
-    [side + 'Class']: {type: 'string'},
-
-    [side + 'Multiple']: {
-      validate: v =>
-        v.sparseArrayOf(
-          v.validateProperties({
-            class: v.optional(v.isString),
-            content: v.isHTML,
-          })),
-    },
-
-    [side + 'StickyMode']: {
-      validate: v => v.is('last', 'column', 'static'),
-      default: 'static',
-    },
-
-    [side + 'Collapse']: {type: 'boolean', default: true},
-
-    [side + 'Wide']: {type: 'boolean', defualt: false},
-  };
-}
-
 export default {
   contentDependencies: [
     'generateColorStyleRules',
     'generateFooterLocalizationLinks',
-    'generatePageSidebar',
-    'generatePageSidebarBox',
     'generateStickyHeadingContainer',
     'transformContent',
   ],
@@ -74,12 +43,6 @@ export default {
     relations.stickyHeadingContainer =
       relation('generateStickyHeadingContainer');
 
-    relations.sidebar =
-      relation('generatePageSidebar');
-
-    relations.sidebarBox =
-      relation('generatePageSidebarBox');
-
     if (sprawl.footerContent) {
       relations.defaultFooterContent =
         relation('transformContent', sprawl.footerContent);
@@ -155,9 +118,6 @@ export default {
       mutable: true,
     },
 
-    ...legacySidebarSlots('leftSidebar'),
-    ...legacySidebarSlots('rightSidebar'),
-
     // Banner
 
     banner: {
@@ -409,44 +369,15 @@ export default {
             slots.navContent),
         ]);
 
-    const applyLegacySidebarSlots = (side, id) =>
-      relations.sidebar.clone().slots({
-        content: slots[side + 'Content'],
-
-        attributes: [
-          {id},
-          slots[side + 'Class'] &&
-            {class: slots[side + 'Class']},
-        ],
-
-        boxes:
-          (slots[side + 'Multiple']
-            ? slots[side + 'Multiple'].map(box =>
-                relations.sidebarBox
-                  .clone()
-                  .slots({
-                    content: box.content,
-                    attributes: {class: box.class},
-                  }))
-            : null),
-
-        stickyMode: slots[side + 'StickyMode'],
-        collapse: slots[side + 'Collapse'],
-        wide: slots[side + 'Wide'],
-      });
-
-    const applyUpdatedSidebar = (side, id) =>
-      slots[side].slots({
-        attributes:
-          slots[side]
-            .getSlotValue('attributes')
-            .with({id}),
-      });
-
     const getSidebar = (side, id) =>
       (html.isBlank(slots[side])
-        ? applyLegacySidebarSlots(side, id)
-        : applyUpdatedSidebar(side, id));
+        ? null
+        : slots[side].slots({
+            attributes:
+              slots[side]
+                .getSlotValue('attributes')
+                .with({id}),
+          }));
 
     const leftSidebar = getSidebar('leftSidebar', 'sidebar-left');
     const rightSidebar = getSidebar('rightSidebar', 'sidebar-right');
@@ -454,7 +385,13 @@ export default {
     const hasSidebarLeft = !html.isBlank(html.resolve(leftSidebar));
     const hasSidebarRight = !html.isBlank(html.resolve(rightSidebar));
 
-    const collapseSidebars = slots.leftSidebarCollapse && slots.rightSidebarCollapse;
+    const collapseSidebars =
+      (leftSidebar
+        ? leftSidebar.getSlotValue('collapse')
+        : true) &&
+      (rightSidebar
+        ? rightSidebar.getSlotValue('collapse')
+        : true);
 
     const hasID = (() => {
       // Hilariously jank. Sorry!