How to use @sveltejs/site-kit - 9 common examples

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 / blog / _posts.js View on Github external
.map(file =&gt; {
			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) =&gt; {
				const fragment = makeSlug(rawtext);

				return `
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';
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>`;
github sveltejs / svelte / site / src / routes / tutorial / [slug] / index.json.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';
			}
		}

		return `<div class="${className}">${prefix}${highlight(source, lang)}</div>`;
	};
github sveltejs / sapper / site / src / utils / generate_docs.js View on Github external
.map(file =&gt; {
			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 = () =&gt; {
				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>
github sveltejs / sapper / site / src / utils / generate_docs.js View on Github external
export default function generate_docs(dir) {
	const make_slug = make_session_slug_processor({
		separator: SLUG_SEPARATOR,
		preserve_unicode: SLUG_PRESERVE_UNICODE
	});

	return fs
		.readdirSync(`content/${dir}`)
		.filter(file => file[0] !== '.' && path.extname(file) === '.md')
		.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 = [];
github sveltejs / svelte / site / src / routes / docs / _sections.js View on Github external
export default function() {
	const make_slug = make_session_slug_processor({
		preserve_unicode: SLUG_PRESERVE_UNICODE,
		separator: SLUG_SEPARATOR
	});

	return fs
		.readdirSync(`content/docs`)
		.filter(file => file[0] !== '.' && path.extname(file) === '.md')
		.map(file => {
			const markdown = fs.readFileSync(`content/docs/${file}`, 'utf-8');

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

			const section_slug = make_slug(metadata.title);

			const subsections = [];

@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