How to use the @sveltejs/site-kit/utils/markdown.extract_frontmatter function in @sveltejs/site-kit

To help you get started, we’ve selected a few @sveltejs/site-kit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sveltejs / svelte / site / src / routes / tutorial / [slug] / index.json.js View on Github external
function get_tutorial(slug) {
	const found = find_tutorial(slug);
	if (!found) return found;

	const dir = `content/tutorial/${found.section}/${found.chapter}`;

	const markdown = fs.readFileSync(`${dir}/text.md`, 'utf-8');
	const app_a = fs.readdirSync(`${dir}/app-a`);
	const app_b = fs.existsSync(`${dir}/app-b`) && fs.readdirSync(`${dir}/app-b`);

	const { content } = extract_frontmatter(markdown);

	const renderer = new marked.Renderer();

	renderer.link = link_renderer;

	renderer.code = (source, lang) => {
		source = source.replace(/^ +/gm, match =>
			match.split('    ').join('\t')
		);

		const lines = source.split('\n');

		const meta = extract_metadata(lines[0], lang);

		let prefix = '';
		let className = 'code-block';

@sveltejs/site-kit

Styles and components for use in *.svelte.dev websites

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis

Similar packages