mirror of https://github.com/sveltejs/svelte
parent
3d87ce0027
commit
15d25b7374
@ -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 };
|
||||
}
|
@ -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);
|
||||
}
|
Loading…
Reference in new issue