浏览代码

Style updates and the like

Craig Fletcher 6 年之前
父节点
当前提交
e94af324b0

+ 11 - 5
.npm-scripts/build-pipeline.js

@@ -175,6 +175,15 @@ module.exports = {
           const dir = dirPath
             .slice(1, dirPath.length - (isIndex ? 1 : 0))
             .join("/");
+          const entries = state
+            .selectByTag("content")
+            .selectByTag("markdown")
+            .matchingAllTags(dirPath)
+            .not(state.selectByTag("index"));
+          const sections = state
+            .matchingAllTags(dirPath)
+            .selectByTag("index")
+            .not([currentItem]);
           return {
             meta: {
               title: currentItem.niceName,
@@ -186,11 +195,8 @@ module.exports = {
               isIndex: isIndex,
               svgs: toNameContentObject(state.selectByTag("svgs")),
               partials: toNameContentObject(state.selectByTag("partials")),
-              entries: state
-                .selectByTag("content")
-                .selectByTag("markdown")
-                .selectByTag(dirPath[1])
-                .not(state.selectByTag("index"))
+              entries: entries,
+              sections: sections
             },
             template: matchingTemplate
           };

+ 13 - 9
.npm-scripts/decorators/articleDecorator.js

@@ -1,16 +1,20 @@
 module.exports = function articleDecorator(config, item, meta) {
-  const introStart = item.content.indexOf("<p>") + 3;
-  const introEnd = item.content.indexOf("</p>");
-  let cutoff;
-  if (introEnd - introStart > config.cutoffLength) {
-    cutoff = item.content.indexOf("p>", introStart + config.cutoffLength) + 1;
-  } else {
-    cutoff = introEnd;
+  let blurb = "No description.";
+  const introMatches = item.content.match(
+    new RegExp("<p>(?<introText>[a-zA-Z0-9 :,.-]+)</p>", "m")
+  );
+
+  if (introMatches) {
+    blurb = introMatches.groups.introText.trim();
   }
-  const blurb = item.content.substring(introStart, cutoff);
+
   const titleStart = item.content.indexOf(">", item.content.indexOf("<h1")) + 1;
   const titleEnd = item.content.indexOf("</h1>");
-  const title = item.content.substring(titleStart, titleEnd) || meta.name;
+  console.log("tts", titleStart, titleEnd);
+  const title =
+    titleEnd > -1
+      ? item.content.substring(titleStart, titleEnd).trim()
+      : meta.name;
   return {
     ...item,
     niceName: title,

+ 62 - 6
package-lock.json

@@ -77,6 +77,11 @@
       "integrity": "sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ==",
       "dev": true
     },
+    "afinn-165": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/afinn-165/-/afinn-165-1.0.4.tgz",
+      "integrity": "sha512-7+Wlx3BImrK0HiG6y3lU4xX7SpBPSSu8T9iguPMlaueRFxjbYwAQrp9lqZUuFikqKbd/en8lVREILvP2J80uJA=="
+    },
     "ansi-regex": {
       "version": "2.1.1",
       "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
@@ -98,6 +103,14 @@
         "picomatch": "^2.0.4"
       }
     },
+    "apparatus": {
+      "version": "0.0.10",
+      "resolved": "https://registry.npmjs.org/apparatus/-/apparatus-0.0.10.tgz",
+      "integrity": "sha512-KLy/ugo33KZA7nugtQ7O0E1c8kQ52N3IvD/XgIh4w/Nr28ypfkwDfA67F1ev4N1m5D+BOk1+b2dEJDfpj/VvZg==",
+      "requires": {
+        "sylvester": ">= 0.0.8"
+      }
+    },
     "arch": {
       "version": "2.1.1",
       "resolved": "https://registry.npmjs.org/arch/-/arch-2.1.1.tgz",
@@ -732,8 +745,7 @@
     "commander": {
       "version": "2.20.3",
       "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
-      "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
-      "dev": true
+      "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="
     },
     "concat-map": {
       "version": "0.0.1",
@@ -1574,7 +1586,7 @@
       "dev": true
     },
     "grapefruit": {
-      "version": "github:leakypixel/grapefruit#df121e98140b04170600624434a4d8e04e4285f2",
+      "version": "github:leakypixel/grapefruit#9a205688040c42d79b57a81432569b896af98b90",
       "from": "github:leakypixel/grapefruit",
       "dev": true
     },
@@ -2285,7 +2297,6 @@
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz",
       "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=",
-      "dev": true,
       "requires": {
         "jsonify": "~0.0.0"
       }
@@ -2293,8 +2304,7 @@
     "jsonify": {
       "version": "0.0.0",
       "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
-      "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
-      "dev": true
+      "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM="
     },
     "junk": {
       "version": "3.1.0",
@@ -2558,6 +2568,18 @@
       "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
       "dev": true
     },
+    "natural": {
+      "version": "0.6.3",
+      "resolved": "https://registry.npmjs.org/natural/-/natural-0.6.3.tgz",
+      "integrity": "sha512-78fcEdNN6Y4pv8SOLPDhJTlUG+8IiQzNx0nYpl0k7q00K4ZZuds+wDWfSa6eeiPcSQDncvV44WWGsi70/ZP3+w==",
+      "requires": {
+        "afinn-165": "^1.0.2",
+        "apparatus": "^0.0.10",
+        "json-stable-stringify": "^1.0.1",
+        "sylvester": "^0.0.12",
+        "underscore": "^1.3.1"
+      }
+    },
     "neo-async": {
       "version": "2.6.1",
       "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz",
@@ -2579,6 +2601,15 @@
         "lower-case": "^1.1.1"
       }
     },
+    "node-summarizer": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/node-summarizer/-/node-summarizer-1.0.7.tgz",
+      "integrity": "sha512-kHgVyhm+k97/50ActxLFIemHLvYPwHLJfwF3tEg2TqeL5xmUCCytqRwdiO3LyBRFMUopLJjisSlkJwTk72gVbg==",
+      "requires": {
+        "natural": "^0.6.3",
+        "wordpos": "^1.2.0"
+      }
+    },
     "normalize-package-data": {
       "version": "2.5.0",
       "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
@@ -3630,6 +3661,11 @@
         }
       }
     },
+    "sylvester": {
+      "version": "0.0.12",
+      "resolved": "https://registry.npmjs.org/sylvester/-/sylvester-0.0.12.tgz",
+      "integrity": "sha1-WohEFc0tACxX56OqyZRip1zp/bQ="
+    },
     "tar-stream": {
       "version": "1.6.2",
       "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz",
@@ -3761,6 +3797,11 @@
         "through": "^2.3.8"
       }
     },
+    "underscore": {
+      "version": "1.10.2",
+      "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.10.2.tgz",
+      "integrity": "sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg=="
+    },
     "unherit": {
       "version": "1.1.2",
       "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.2.tgz",
@@ -3972,6 +4013,21 @@
         "isexe": "^2.0.0"
       }
     },
+    "wordnet-db": {
+      "version": "3.1.14",
+      "resolved": "https://registry.npmjs.org/wordnet-db/-/wordnet-db-3.1.14.tgz",
+      "integrity": "sha512-zVyFsvE+mq9MCmwXUWHIcpfbrHHClZWZiVOzKSxNJruIcFn2RbY55zkhiAMMxM8zCVSmtNiViq8FsAZSFpMYag=="
+    },
+    "wordpos": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/wordpos/-/wordpos-1.2.0.tgz",
+      "integrity": "sha512-3C0pdLnYIV962dyPEmi+QNJhI+RRz2lLY1QiCycUt2qhL8Dalv1huAngfePDmNJ1WHdSAT/fjbDqtbu1KfguCw==",
+      "requires": {
+        "commander": "^2.0.0",
+        "underscore": ">=1.3.1",
+        "wordnet-db": "^3.1.6"
+      }
+    },
     "wordwrap": {
       "version": "0.0.3",
       "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",

+ 2 - 1
package.json

@@ -18,7 +18,8 @@
   },
   "dependencies": {
     "chokidar": "^3.3.1",
-    "ecstatic": "^4.1.2"
+    "ecstatic": "^4.1.2",
+    "node-summarizer": "^1.0.7"
   },
   "homepage": "https://leakypixel.net/",
   "devDependencies": {

+ 0 - 0
pages/article.handlebars → pages/food/article.handlebars


+ 27 - 0
pages/food/index.handlebars

@@ -0,0 +1,27 @@
+{{> header }}
+<section>
+  <h1>{{meta.title}}</h1>
+</section>
+  {{#if meta.sections}}
+<section>
+  {{#each meta.sections}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}} </a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{/if}}
+<section>
+{{#each meta.entries}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}}</a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{> footer }}

+ 13 - 1
pages/index.handlebars

@@ -1,5 +1,17 @@
 {{> header }}
 <section>
-  {{{ item.content }}}
+  <h1>{{meta.title}}</h1>
 </section>
+  {{#if meta.sections}}
+<section>
+  {{#each meta.sections}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}}</a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{/if}}
 {{> footer }}

+ 5 - 0
pages/lists/article.handlebars

@@ -0,0 +1,5 @@
+{{> header }}
+<section>
+  {{{ item.content }}}
+</section>
+{{> footer }}

+ 27 - 0
pages/lists/index.handlebars

@@ -0,0 +1,27 @@
+{{> header }}
+<section>
+  <h1>{{meta.title}}</h1>
+</section>
+  {{#if meta.sections}}
+<section>
+  {{#each meta.sections}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}} </a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{/if}}
+<section>
+{{#each meta.entries}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}}</a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{> footer }}

+ 5 - 0
pages/misc/article.handlebars

@@ -0,0 +1,5 @@
+{{> header }}
+<section>
+  {{{ item.content }}}
+</section>
+{{> footer }}

+ 27 - 0
pages/misc/index.handlebars

@@ -0,0 +1,27 @@
+{{> header }}
+<section>
+  <h1>{{meta.title}}</h1>
+</section>
+  {{#if meta.sections}}
+<section>
+  {{#each meta.sections}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}} </a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{/if}}
+<section>
+{{#each meta.entries}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}}</a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{> footer }}

+ 5 - 0
pages/projects/article.handlebars

@@ -0,0 +1,5 @@
+{{> header }}
+<section>
+  {{{ item.content }}}
+</section>
+{{> footer }}

+ 27 - 0
pages/projects/index.handlebars

@@ -0,0 +1,27 @@
+{{> header }}
+<section>
+  <h1>{{meta.title}}</h1>
+</section>
+  {{#if meta.sections}}
+<section>
+  {{#each meta.sections}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}} </a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{/if}}
+<section>
+{{#each meta.entries}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}}</a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{> footer }}

+ 5 - 0
pages/technical/article.handlebars

@@ -0,0 +1,5 @@
+{{> header }}
+<section>
+  {{{ item.content }}}
+</section>
+{{> footer }}

+ 27 - 0
pages/technical/index.handlebars

@@ -0,0 +1,27 @@
+{{> header }}
+<section>
+  <h1>{{meta.title}}</h1>
+</section>
+  {{#if meta.sections}}
+<section>
+  {{#each meta.sections}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}} </a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{/if}}
+<section>
+{{#each meta.entries}}
+  <article>
+    <h2>
+      <a href="{{outputPath}}">{{{ niceName }}}</a>
+    </h2>
+    <p>{{{ blurb }}}</p>
+  </article>
+{{/each}}
+</section>
+{{> footer }}

+ 15 - 5
styles/styles.css

@@ -79,7 +79,21 @@ code {
 }
 
 article {
-  margin: 1em auto 4em auto;
+  margin: 1em;
+  display: inline-block;
+  background-color: var(--color-background-alternative);
+  padding: 1em;
+  max-width: 340px;
+}
+
+article h2 {
+  font-family: "NotoSerif", serif;
+  margin-top: 0;
+}
+
+article p {
+  margin-bottom: 0;
+  font-size: 0.8em;
 }
 
 section img {
@@ -112,10 +126,6 @@ h2 {
   margin: 2em 0 1em 0;
 }
 
-article h2 {
-  margin-top: 2em;
-}
-
 h3 {
   display: block;
   margin: 1.6em 0 1em 0;