How to use the @sveltejs/site-kit/utils/markdown.js.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 / blog / _posts.js View on Github external
.map(file => {
			if (path.extname(file) !== '.md') return;

			const match = /^(\d+-\d+-\d+)-(.+)\.md$/.exec(file);
			if (!match) throw new Error(`Invalid filename '${file}'`);

			const [, pubdate, slug] = match;

			const markdown = fs.readFileSync(`content/blog/${file}`, 'utf-8');

			const { content, metadata } = extract_frontmatter(markdown);

			const date = new Date(`${pubdate} EDT`); // cheeky hack
			metadata.pubdate = pubdate;
			metadata.dateString = date.toDateString();

			const renderer = new marked.Renderer();

			renderer.link = link_renderer;

			renderer.code = highlight;

			renderer.heading = (text, level, rawtext) => {
				const fragment = makeSlug(rawtext);

				return `
github sveltejs / sapper / site / src / utils / generate_docs.js View on Github external
.map(file => {
			const markdown = fs.readFileSync(`content/${dir}/${file}`, 'utf-8');

			const { content, metadata } = extract_frontmatter(markdown);

			const section_slug = make_slug(metadata.title);

			const subsections = [];

			const renderer = new marked.Renderer();

			let block_open = false;

			renderer.link = link_renderer;

			renderer.hr = () => {
				block_open = true;

				return '<div class="side-by-side"><div class="copy">';
			};</div></div>
github sveltejs / svelte / site / src / routes / docs / _sections.js View on Github external
.map(file =&gt; {
			const markdown = fs.readFileSync(`content/docs/${file}`, 'utf-8');

			const { content, metadata } = extract_frontmatter(markdown);

			const section_slug = make_slug(metadata.title);

			const subsections = [];

			const renderer = new marked.Renderer();

			let block_open = false;

			renderer.link = link_renderer;

			renderer.hr = () =&gt; {
				block_open = true;

				return '<div class="side-by-side"><div class="copy">';
			};</div></div>

@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