Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/compile/internal_exports.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions sites/svelte.dev/src/routes/+layout.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@ export const load = async ({ url, fetch }) => {
const nav_list = await fetch('/nav.json').then((r) => r.json());

return {
nav_title: get_nav_title(url),
nav_links: nav_list
nav: {
title: get_nav_title(url),
links: nav_list
},
search: {
priority_map: get_search_priority_list()
}
};
};

/** @returns {Record<string, number>} */
function get_search_priority_list() {
return {
'docs/v4-migration-guide': 2,
'docs/typescript': 3,
docs: 4
};
}

/** @param {URL} url */
function get_nav_title(url) {
const list = new Map([
Expand Down
2 changes: 1 addition & 1 deletion sites/svelte.dev/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<div style:display={$page.url.pathname !== '/docs' ? 'contents' : 'none'}>
<Shell nav_visible={$page.url.pathname !== '/repl/embed'}>
<Nav slot="top-nav" title={data.nav_title} links={data.nav_links}>
<Nav slot="top-nav" title={data.nav.title} links={data.nav.links}>
<svelte:fragment slot="home-large">
<strong>svelte</strong>.dev
</svelte:fragment>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 16 additions & 15 deletions sites/svelte.dev/src/routes/content.json/content.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export async function content() {
const slug = match[1];

const filepath = `${base}/docs/${file}`;
const markdown = replaceExportTypePlaceholders(await readFile(filepath, 'utf-8'), modules);
// const markdown = replace_placeholders(fs.readFileSync(filepath, 'utf-8'));
const markdown = replaceExportTypePlaceholders(
remove_export_snippets(await readFile(filepath, 'utf-8')),
modules
);

const { body, metadata } = extractFrontmatter(markdown);

Expand All @@ -45,7 +49,7 @@ export async function content() {
const rank = +metadata.rank || undefined;

blocks.push({
breadcrumbs: [...breadcrumbs, removeMarkdown(remove_TYPE(metadata.title) ?? '')],
breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title ?? '')],
href: get_href([slug]),
content: plaintext(intro),
rank
Expand All @@ -61,11 +65,7 @@ export async function content() {
const intro = subsections.shift().trim();

blocks.push({
breadcrumbs: [
...breadcrumbs,
removeMarkdown(remove_TYPE(metadata.title)),
remove_TYPE(removeMarkdown(h2))
],
breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title), removeMarkdown(h2)],
href: get_href([slug, normalizeSlugify(h2)]),
content: plaintext(intro),
rank
Expand All @@ -78,9 +78,9 @@ export async function content() {
blocks.push({
breadcrumbs: [
...breadcrumbs,
removeMarkdown(remove_TYPE(metadata.title)),
removeMarkdown(remove_TYPE(h2)),
removeMarkdown(remove_TYPE(h3))
removeMarkdown(metadata.title),
removeMarkdown(h2),
removeMarkdown(h3)
],
href: get_href([slug, normalizeSlugify(h2) + '-' + normalizeSlugify(h3)]),
content: plaintext(lines.join('\n').trim()),
Expand All @@ -93,11 +93,6 @@ export async function content() {
return blocks;
}

/** @param {string} str */
function remove_TYPE(str) {
return str?.replace(/^\[TYPE\]:\s+(.+)/, '$1') ?? '';
}

/** @param {string} markdown */
function plaintext(markdown) {
/** @param {unknown} text */
Expand Down Expand Up @@ -137,3 +132,9 @@ function plaintext(markdown) {
})
.trim();
}

/** @param {string} markdown */
function remove_export_snippets(markdown) {
// Remove any > EXPORT_SNIPPET: svelte/store#writable
return markdown.replace(/^> EXPORT_SNIPPET: .+$/gm, '');
}