Explorar o código

Separate indexes rendering

Craig Fletcher %!s(int64=6) %!d(string=hai) anos
pai
achega
a2a7ab75e8
Modificáronse 2 ficheiros con 32 adicións e 4 borrados
  1. 31 3
      .npm-scripts/build-pipeline.js
  2. 1 1
      styles/styles.css

+ 31 - 3
.npm-scripts/build-pipeline.js

@@ -160,7 +160,7 @@ module.exports = {
       {
         func: "renderTemplate",
         deferConfig: true,
-        selector: state => state.selectByTag("content"),
+        selector: state => state.selectByTag("content").selectByTag("index"),
         getConfig: (state, currentItem) => {
           const matchingTemplate = state
             .selectByTag("pages")
@@ -181,14 +181,13 @@ module.exports = {
             .selectByTag("index")
             .not([currentItem])
             .selectMany(item => item.depth <= currentItem.depth + 1);
-          const isIndex = currentItem.tags.includes("index");
           return {
             meta: {
               title: currentItem.niceName,
               name: currentItem.name,
               now: new Date().toLocaleString(),
               context: currentItem.dirPath[1],
-              isIndex: isIndex,
+              isIndex: true,
               svgs: toNameContentObject(state.selectByTag("svgs")),
               partials: toNameContentObject(state.selectByTag("partials")),
               entries: entries,
@@ -199,6 +198,35 @@ module.exports = {
           };
         }
       },
+      {
+        func: "renderTemplate",
+        deferConfig: true,
+        selector: state =>
+          state.selectByTag("content").not(state.selectByTag("index")),
+        getConfig: (state, currentItem) => {
+          const matchingTemplate = state
+            .selectByTag("pages")
+            .mostMatchingTags(currentItem.tags);
+          console.log(
+            `Rendering ${currentItem.dir}/${currentItem.name} with ${
+              matchingTemplate.dir
+            }/${matchingTemplate.name}`
+          );
+          return {
+            meta: {
+              title: currentItem.niceName,
+              name: currentItem.name,
+              now: new Date().toLocaleString(),
+              context: currentItem.dirPath[1],
+              isIndex: false,
+              svgs: toNameContentObject(state.selectByTag("svgs")),
+              partials: toNameContentObject(state.selectByTag("partials")),
+              trail: [...currentItem.dirPath.slice(1), currentItem.name]
+            },
+            template: matchingTemplate
+          };
+        }
+      },
       {
         func: "copy",
         selector: state =>

+ 1 - 1
styles/styles.css

@@ -537,7 +537,7 @@ header {
 .hljs-comment,
 .hljs-quote,
 .hljs-meta {
-  color: #444;
+  color: #7e7979;
 }
 .hljs-string,
 .hljs-symbol,