|
|
@ -33,7 +33,12 @@ export function content() {
|
|
|
|
|
|
|
|
|
|
|
|
const filepath = `${base}/docs/${file}`;
|
|
|
|
const filepath = `${base}/docs/${file}`;
|
|
|
|
// const markdown = replace_placeholders(fs.readFileSync(filepath, 'utf-8'));
|
|
|
|
// const markdown = replace_placeholders(fs.readFileSync(filepath, 'utf-8'));
|
|
|
|
const markdown = replaceExportTypePlaceholders(fs.readFileSync(filepath, 'utf-8'), modules);
|
|
|
|
const markdown = replaceExportTypePlaceholders(
|
|
|
|
|
|
|
|
remove_export_snippets(fs.readFileSync(filepath, 'utf-8')),
|
|
|
|
|
|
|
|
modules
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (markdown.includes('writable')) console.log(markdown);
|
|
|
|
|
|
|
|
|
|
|
|
const { body, metadata } = extractFrontmatter(markdown);
|
|
|
|
const { body, metadata } = extractFrontmatter(markdown);
|
|
|
|
|
|
|
|
|
|
|
@ -42,7 +47,7 @@ export function content() {
|
|
|
|
const rank = +metadata.rank || undefined;
|
|
|
|
const rank = +metadata.rank || undefined;
|
|
|
|
|
|
|
|
|
|
|
|
blocks.push({
|
|
|
|
blocks.push({
|
|
|
|
breadcrumbs: [...breadcrumbs, removeMarkdown(remove_TYPE(metadata.title) ?? '')],
|
|
|
|
breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title ?? '')],
|
|
|
|
href: get_href([slug]),
|
|
|
|
href: get_href([slug]),
|
|
|
|
content: plaintext(intro),
|
|
|
|
content: plaintext(intro),
|
|
|
|
rank
|
|
|
|
rank
|
|
|
@ -58,11 +63,7 @@ export function content() {
|
|
|
|
const intro = subsections.shift().trim();
|
|
|
|
const intro = subsections.shift().trim();
|
|
|
|
|
|
|
|
|
|
|
|
blocks.push({
|
|
|
|
blocks.push({
|
|
|
|
breadcrumbs: [
|
|
|
|
breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title), removeMarkdown(h2)],
|
|
|
|
...breadcrumbs,
|
|
|
|
|
|
|
|
removeMarkdown(remove_TYPE(metadata.title)),
|
|
|
|
|
|
|
|
remove_TYPE(removeMarkdown(h2))
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
href: get_href([slug, normalizeSlugify(h2)]),
|
|
|
|
href: get_href([slug, normalizeSlugify(h2)]),
|
|
|
|
content: plaintext(intro),
|
|
|
|
content: plaintext(intro),
|
|
|
|
rank
|
|
|
|
rank
|
|
|
@ -75,9 +76,9 @@ export function content() {
|
|
|
|
blocks.push({
|
|
|
|
blocks.push({
|
|
|
|
breadcrumbs: [
|
|
|
|
breadcrumbs: [
|
|
|
|
...breadcrumbs,
|
|
|
|
...breadcrumbs,
|
|
|
|
removeMarkdown(remove_TYPE(metadata.title)),
|
|
|
|
removeMarkdown(metadata.title),
|
|
|
|
removeMarkdown(remove_TYPE(h2)),
|
|
|
|
removeMarkdown(h2),
|
|
|
|
removeMarkdown(remove_TYPE(h3))
|
|
|
|
removeMarkdown(h3)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
href: get_href([slug, normalizeSlugify(h2) + '-' + normalizeSlugify(h3)]),
|
|
|
|
href: get_href([slug, normalizeSlugify(h2) + '-' + normalizeSlugify(h3)]),
|
|
|
|
content: plaintext(lines.join('\n').trim()),
|
|
|
|
content: plaintext(lines.join('\n').trim()),
|
|
|
@ -90,11 +91,6 @@ export function content() {
|
|
|
|
return blocks;
|
|
|
|
return blocks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {string} str */
|
|
|
|
|
|
|
|
function remove_TYPE(str) {
|
|
|
|
|
|
|
|
return str?.replace(/^\[TYPE\]:\s+(.+)/, '$1') ?? '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {string} markdown */
|
|
|
|
/** @param {string} markdown */
|
|
|
|
function plaintext(markdown) {
|
|
|
|
function plaintext(markdown) {
|
|
|
|
/** @param {unknown} text */
|
|
|
|
/** @param {unknown} text */
|
|
|
@ -134,3 +130,9 @@ function plaintext(markdown) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.trim();
|
|
|
|
.trim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {string} markdown */
|
|
|
|
|
|
|
|
function remove_export_snippets(markdown) {
|
|
|
|
|
|
|
|
// Remove any > EXPORT_SNIPPET: svelte/store#writable
|
|
|
|
|
|
|
|
return markdown.replace(/^> EXPORT_SNIPPET: .+$/gm, '');
|
|
|
|
|
|
|
|
}
|
|
|
|