Some fixes

This commit is contained in:
ポール ウェッブ 2018-10-11 17:10:32 -05:00
parent 8a20651804
commit dbd3da4680
4 changed files with 34 additions and 11 deletions

View file

@ -1,6 +1,16 @@
"use strict";
import markdown from "../markdown";
// P A C K A G E
import { require as local } from "app-root-path";
// U T I L
const markdown = local("/app/components/markdown").default;
// E X P O R T

View file

@ -1,19 +1,28 @@
"use strict";
// P A C K A G E S
import decamelize from "decamelize";
import exists from "fs-exists-sync";
import fs from "graceful-fs";
import fm from "front-matter";
import fs from "graceful-fs";
import html from "choo/html";
import path from "path";
import raw from "choo/html/raw";
import { require as local } from "app-root-path";
// V A R I A B L E
const numberRegex = /^[0-9]/g;
// U T I L
const md = require("markdown-it")({
html: true,
typographer: true
}).use(local("app/modules/markdown-it-sup"))
}).use(local("/app/modules/markdown-it-sup"))
.use(require("markdown-it-anchor"), {
slugify: stringToSlugify => {
let finalString = stringToSlugify
@ -32,8 +41,9 @@ const md = require("markdown-it")({
export default path => {
// E X P O R T
export default path => {
const markdownFile = fs.readFileSync(path, "utf-8");
const markdownFileDetails = fm(markdownFile);
const renderedMarkdown = md.render(markdownFileDetails.body);
@ -44,6 +54,10 @@ export default path => {
`;
};
// H E L P E R
function partialFinder(markdownBody) {
const regexToFindPartials = /<\w+ ?\/>/g;
const partials = markdownBody.match(regexToFindPartials);
@ -76,7 +90,7 @@ function wikiFinder(markdownBody) {
const url = encodeURI("/glossary#" + label.replace(/\s+/g, "-"));
return label ?
`<a href="${url}" class="link--glossary">${label}</a>` :
`<a class="link--glossary" href="${url}">${label}</a>` :
match.input;
});
}

View file

@ -9,8 +9,8 @@ import { require as local } from "app-root-path";
// U T I L S
const page404 = local("app/views/404.js");
const redirects = local("app/data/redirects.json");
const page404 = local("/app/views/404.js");
const redirects = local("/app/data/redirects.json");

View file

@ -12,7 +12,7 @@ import raw from "choo/html/raw";
// U T I L S
const markdown = local("/app/components/markdown");
const markdown = local("/app/components/markdown").default;
const redirect404 = local("/app/modules/redirect-404");
@ -23,9 +23,8 @@ module.exports = exports = (state, emit) => { // eslint-disable-line
const partialPath = state.route === "resources/*" ? `resources/${state.params.wildcard}` : state.params.wildcard;
const path = `./documents/${partialPath}.md`;
if (!fs.existsSync(path)) {
if (!fs.existsSync(path))
return redirect404(state);
}
const markdownFile = fs.readFileSync(path, "utf-8");
const markdownFileDetails = fm(markdownFile);
@ -49,7 +48,7 @@ module.exports = exports = (state, emit) => { // eslint-disable-line
if (partialPath === "glossary") pageScript = "<script>" + fs.readFileSync("./app/components/client/glossary-scripts.js", "utf-8") + "</script>";
if (partialPath === "overview") pageScript = "<script>" + fs.readFileSync("./app/components/client/ecosystem-scripts.js", "utf-8") + "</script>";
if (partialPath === "playground") pageScript = "<script>" + fs.readFileSync("./app/components/client/playground-scripts.js", "utf-8") + "</script>";
// console.log(markdown(path));
return html`
<article class="page" itemtype="http://schema.org/BlogPosting">
<header class="page__header">