Jelajahi Sumber

Add autolinking

Craig Fletcher 6 tahun lalu
induk
melakukan
f4f5d21c45

+ 1 - 1
.npm-scripts/build-pipeline.js

@@ -193,7 +193,7 @@ module.exports = {
               partials: toNameContentObject(state.selectByTag("partials")),
               entries: entries,
               sections: sections,
-              outputPath: currentItem.dirPath.slice(1)
+              trail: [...currentItem.dirPath.slice(1), currentItem.name]
             },
             template: matchingTemplate
           };

+ 1 - 1
.npm-scripts/decorators/articleDecorator.js

@@ -15,7 +15,7 @@ module.exports = function articleDecorator(config, item, meta) {
       : meta.name;
   return {
     ...item,
-    niceName: title,
+    niceName: title.replace(/<[^>]*>?/gm, ""),
     blurb: blurb,
     tags: [].concat(item.tags, ["article"])
   };

+ 1 - 0
.npm-scripts/decorators/outputDecorator.js

@@ -2,6 +2,7 @@ const path = require("path");
 
 module.exports = function outputDecorator(config, item, meta) {
   const outputDir = path.join(meta.dir.replace(config.baseDir, ""));
+  console.log("OPD", `${path.join(outputDir, meta.name)}`);
   return {
     ...item,
     outputPath: `${path.join(outputDir, meta.name)}`,

+ 1 - 1
.npm-scripts/funcs/markdownToHtml.js

@@ -2,7 +2,7 @@ const hubdown = require("hubdown");
 
 module.exports = function(config, item) {
   return new Promise(function(resolve) {
-    hubdown(item.content, { ignore: ["autolinkHeadings"] }).then(doc => {
+    hubdown(item.content).then(doc => {
       resolve({
         ...item,
         content: doc.content

+ 0 - 7
helpers/breadcrumb.js

@@ -13,13 +13,6 @@ module.exports = function(context, options) {
           </li></a>`;
       })
       .join("\n")}
-      ${
-        meta.isIndex
-          ? ""
-          : `<a href="${meta.outputPath}" title="${meta.name}"><li>
-    ${meta.name}
-    </li></a>`
-      }
     </ul>
     `;
 };

+ 2 - 1
pages/index.handlebars

@@ -1,7 +1,8 @@
 {{> header }}
 <main>
 <section>
-  <h1>{{meta.title}}</h1>
+  <h1><a title="{{meta.name}}" href="{{meta.outputPath}}">{{meta.title}}</a></h1>
+  {{meta.outputPath}}
 </section>
   {{#if meta.sections}}
 <section class="filetree">

+ 1 - 1
partials/header.handlebars

@@ -29,6 +29,6 @@
       </button>
     </div>
 
-    {{#breadcrumb meta.outputPath}}
+    {{#breadcrumb meta.trail}}
     {{/breadcrumb}}
 </header>