Launch-ish #163

Merged
kauffj merged 14 commits from launch into master 2018-10-01 17:21:11 +02:00
3 changed files with 5 additions and 10 deletions
Showing only changes of commit 28b56b0d39 - Show all commits

View file

@ -6,6 +6,7 @@
import asyncHtml from "choo-async/html"; import asyncHtml from "choo-async/html";
import dedent from "dedent"; import dedent from "dedent";
import redirectOr404 from "../modules/redirectOr404";
const fetch = require("make-fetch-happen").defaults({ cacheManager: "./cache" }); const fetch = require("make-fetch-happen").defaults({ cacheManager: "./cache" });
@ -59,6 +60,8 @@ module.exports = exports = state => parseApiFile(state.params.wildcard).then(res
<script src="/assets/scripts/plugins/jets.js"></script> <script src="/assets/scripts/plugins/jets.js"></script>
<script src="/assets/scripts/api.js"></script> <script src="/assets/scripts/api.js"></script>
`; `;
}).catch(() => {
redirectOr404(state.href);
}); });

View file

@ -11,9 +11,7 @@ import fs from "graceful-fs";
import html from "choo/html"; import html from "choo/html";
import path from "path"; import path from "path";
import { require as local } from "app-root-path"; import { require as local } from "app-root-path";
import redirects from "../data/redirects.json"; import redirectOr404 from "../modules/redirectOr404";
import redirect from "../modules/redirect";
import Page404 from "./404.js";
import raw from "choo/html/raw"; import raw from "choo/html/raw";
// V A R I A B L E S // V A R I A B L E S
@ -44,17 +42,11 @@ const md = require("markdown-it")({
module.exports = exports = (state, emit) => { // eslint-disable-line module.exports = exports = (state, emit) => { // eslint-disable-line
let path; let path;
if (state.route === "resources/*") path = `resources/${state.params.wildcard}`; if (state.route === "resources/*") path = `resources/${state.params.wildcard}`;
else path = state.params.wildcard; else path = state.params.wildcard;
if (!fs.existsSync(`./documents/${path}.md`)) { if (!fs.existsSync(`./documents/${path}.md`)) {
const redirectUrl = redirects[path] || redirects["/" + path]; return redirectOr404(state.href);
if (redirectUrl) {
redirect(redirectUrl);
} else {
return Page404();
}
} }
const markdownFile = fs.readFileSync(`./documents/${path}.md`, "utf-8"); const markdownFile = fs.readFileSync(`./documents/${path}.md`, "utf-8");