From 15d25b7374663a85d089365c4f1c09a50e5e8921 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 19 Dec 2018 18:04:34 -0500 Subject: [PATCH] shuffle some things about --- site/src/routes/api/_process_markdown.js | 15 ------------- site/src/routes/api/blog/_posts.js | 2 +- site/src/routes/api/guide/contents.js | 21 ------------------- site/src/routes/{api => }/guide/_sections.js | 2 +- .../[hash].js => guide/demo/[hash].json.js} | 0 site/src/routes/guide/index.html | 2 +- .../guide/index.js => guide/index.json.js} | 0 7 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 site/src/routes/api/_process_markdown.js delete mode 100644 site/src/routes/api/guide/contents.js rename site/src/routes/{api => }/guide/_sections.js (98%) rename site/src/routes/{api/guide/demo/[hash].js => guide/demo/[hash].json.js} (100%) rename site/src/routes/{api/guide/index.js => guide/index.json.js} (100%) diff --git a/site/src/routes/api/_process_markdown.js b/site/src/routes/api/_process_markdown.js deleted file mode 100644 index a79d759cbb..0000000000 --- a/site/src/routes/api/_process_markdown.js +++ /dev/null @@ -1,15 +0,0 @@ -export default function process_markdown(markdown) { - const match = /---\n([\s\S]+?)\n---/.exec(markdown); - const frontMatter = match[1]; - const content = markdown.slice(match[0].length); - - const metadata = {}; - frontMatter.split('\n').forEach(pair => { - const colonIndex = pair.indexOf(':'); - metadata[pair.slice(0, colonIndex).trim()] = pair - .slice(colonIndex + 1) - .trim(); - }); - - return { metadata, content }; -} \ No newline at end of file diff --git a/site/src/routes/api/blog/_posts.js b/site/src/routes/api/blog/_posts.js index 06e87a3575..5a9765dfd0 100644 --- a/site/src/routes/api/blog/_posts.js +++ b/site/src/routes/api/blog/_posts.js @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import process_markdown from '../_process_markdown.js'; +import process_markdown from '../../../utils/_process_markdown.js'; import marked from 'marked'; // import hljs from 'highlight.js'; diff --git a/site/src/routes/api/guide/contents.js b/site/src/routes/api/guide/contents.js deleted file mode 100644 index 31e78e4b03..0000000000 --- a/site/src/routes/api/guide/contents.js +++ /dev/null @@ -1,21 +0,0 @@ -import get_sections from './_sections.js'; - -let json; - -export function get(req, res) { - if (!json || process.env.NODE_ENV !== 'production') { - json = JSON.stringify(get_sections().map(section => { - return { - metadata: section.metadata, - subsections: section.subsections, - slug: section.slug - }; - })); - } - - res.set({ - 'Content-Type': 'application/json' - }); - - res.end(json); -} \ No newline at end of file diff --git a/site/src/routes/api/guide/_sections.js b/site/src/routes/guide/_sections.js similarity index 98% rename from site/src/routes/api/guide/_sections.js rename to site/src/routes/guide/_sections.js index d53f539b13..f60cdee42b 100644 --- a/site/src/routes/api/guide/_sections.js +++ b/site/src/routes/guide/_sections.js @@ -1,7 +1,7 @@ import fs from 'fs'; import path from 'path'; import * as fleece from 'golden-fleece'; -import process_markdown from '../_process_markdown.js'; +import process_markdown from '../../utils/_process_markdown.js'; import marked from 'marked'; import prismjs from 'prismjs'; // prism-highlighter – smaller footprint [hljs: 192.5k] diff --git a/site/src/routes/api/guide/demo/[hash].js b/site/src/routes/guide/demo/[hash].json.js similarity index 100% rename from site/src/routes/api/guide/demo/[hash].js rename to site/src/routes/guide/demo/[hash].json.js diff --git a/site/src/routes/guide/index.html b/site/src/routes/guide/index.html index 7b92baf531..c0eb8be74d 100644 --- a/site/src/routes/guide/index.html +++ b/site/src/routes/guide/index.html @@ -1,6 +1,6 @@ diff --git a/site/src/routes/api/guide/index.js b/site/src/routes/guide/index.json.js similarity index 100% rename from site/src/routes/api/guide/index.js rename to site/src/routes/guide/index.json.js