« get me outta code hell

content: generatePageLayout: footer :sparkles: - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-04-08 18:18:32 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-04-08 18:26:12 -0300
commit7f32560a93500777a877fd8f30a21c994662ae65 (patch)
tree558ffadb9480822478a3d9c7dbc06a00bdc6c82c
parent76845689c624b603509abbe6f0a289362bb42a04 (diff)
content: generatePageLayout: footer :sparkles:
-rw-r--r--src/content/dependencies/generatePageLayout.js43
-rw-r--r--src/content/dependencies/index.js2
2 files changed, 42 insertions, 3 deletions
diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js
index 9abac0a2..98b2d350 100644
--- a/src/content/dependencies/generatePageLayout.js
+++ b/src/content/dependencies/generatePageLayout.js
@@ -1,15 +1,33 @@
 export default {
+  contentDependencies: [
+    'generateFooterLocalizationLinks',
+  ],
+
   extraDependencies: [
+    'cachebust',
     'html',
     'language',
     'to',
+    'transformMultiline',
+    'wikiInfo',
   ],
 
-  generate({
+  relations(relation) {
+    const relations = {};
+
+    relations.footerLocalizationLinks =
+      relation('generateFooterLocalizationLinks');
+
+    return relations;
+  },
+
+  generate(relations, {
     cachebust,
     html,
     language,
     to,
+    transformMultiline,
+    wikiInfo,
   }) {
     return html.template({
       annotation: 'generatePageLayout',
@@ -19,6 +37,7 @@ export default {
         cover: {type: 'html'},
 
         mainContent: {type: 'html'},
+        footerContent: {type: 'html'},
         socialEmbed: {type: 'html'},
 
         headingMode: {
@@ -58,6 +77,12 @@ export default {
           }
         }
 
+        let footerContent = slots.footerContent;
+
+        if (html.isBlank(footerContent) && wikiInfo.footerContent) {
+          footerContent = transformMultiline(wikiInfo.footerContent);
+        }
+
         const mainHTML =
           html.tag('main', {
             id: 'content',
@@ -75,6 +100,20 @@ export default {
               slots.mainContent),
           ]);
 
+        const footerHTML =
+          html.tag('footer',
+            {[html.onlyIfContent]: true, id: 'footer'},
+            [
+              html.tag('div',
+                {
+                  [html.onlyIfContent]: true,
+                  class: 'footer-content',
+                },
+                footerContent),
+
+              relations.footerLocalizationLinks,
+            ]);
+
         const layoutHTML = [
           // navHTML,
           // banner.position === 'top' && bannerHTML,
@@ -97,7 +136,7 @@ export default {
               // sidebarRightHTML,
             ]),
           // banner.position === 'bottom' && bannerHTML,
-          // footerHTML,
+          footerHTML,
         ].filter(Boolean).join('\n');
 
         const documentHTML = html.tags([
diff --git a/src/content/dependencies/index.js b/src/content/dependencies/index.js
index d5ac082f..1210d78e 100644
--- a/src/content/dependencies/index.js
+++ b/src/content/dependencies/index.js
@@ -156,7 +156,7 @@ export function watchContentDependencies({
         break main;
       }
 
-      if (logging && contentDependencies[functionName]) {
+      if (logging && initialScanComplete) {
         const timestamp = new Date().toLocaleString('en-US', {timeStyle: 'medium'});
         console.log(color.green(`[${timestamp}] Updated ${functionName}`));
       }