How to use the @sveltejs/site-kit/utils/markdown.js.extract_metadata 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 / sapper / site / src / utils / generate_docs.js View on Github external
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 class_name = 'code-block';
				let class_name = '';

				if (meta) {
					source = lines.slice(1).join('\n');
					const filename = meta.filename || (lang === 'html' && 'App.svelte');
					if (filename) {
						prefix = `<span class="filename">${prefix} ${filename}</span>`;
						class_name += ' named';
					}
				}

				if (meta &amp;&amp; meta.hidden) {
					return '';
github sveltejs / svelte / site / src / routes / docs / _sections.js View on Github external
renderer.code = (source, lang) =&gt; {
				source = source.replace(/^ +/gm, match =&gt;
					match.split('    ').join('\t')
				);

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

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

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

				if (meta) {
					source = lines.slice(1).join('\n');
					const filename = meta.filename || (lang === 'html' &amp;&amp; 'App.svelte');
					if (filename) {
						prefix = `<span class="filename">${prefix} ${filename}</span>`;
						className += ' named';
					}
				}

				if (meta &amp;&amp; meta.hidden) return '';

				const html = `<div class="${className}">${prefix}${highlight(source, lang)}</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