diff --git a/site/content/docs/16-migrating.md b/site/content/migration/01-migrating.md similarity index 100% rename from site/content/docs/16-migrating.md rename to site/content/migration/01-migrating.md diff --git a/site/package-lock.json b/site/package-lock.json index 819344e..ba4fd45 100644 --- a/site/package-lock.json +++ b/site/package-lock.json @@ -857,11 +857,11 @@ } }, "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.6.tgz", + "integrity": "sha512-QsaoUD2dpVpjENy8JFpQnXP9vyzoZPmAoKrE3S6HtSB7qzSebkJNnmdY4p004FQUSSiHXPueENpoeuUW/7a8Ig==", "requires": { - "mime-types": "~2.1.18", + "mime-types": "~2.1.24", "negotiator": "0.6.1" } }, @@ -1648,8 +1648,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -1670,14 +1669,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1692,20 +1689,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -1822,8 +1816,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -1835,7 +1828,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1850,7 +1842,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1858,14 +1849,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -1884,7 +1873,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -1965,8 +1953,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -1978,7 +1965,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2064,8 +2050,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2101,7 +2086,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2121,7 +2105,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2165,14 +2148,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -3098,9 +3079,9 @@ } }, "regexp-tree": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.5.tgz", - "integrity": "sha512-nUmxvfJyAODw+0B13hj8CFVAxhe7fDEAgJgaotBu3nnR+IgGgZq59YedJP5VYTlkEfqjuK6TuRpnymKdatLZfQ==", + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.6.tgz", + "integrity": "sha512-LFrA98Dw/heXqDojz7qKFdygZmFoiVlvE1Zp7Cq2cvF+ZA+03Gmhy0k0PQlsC1jvHPiTUSs+pDHEuSWv6+6D7w==", "dev": true }, "regexpu-core": { diff --git a/site/src/routes/docs/_GuideContents.svelte b/site/src/routes/docs/_GuideContents.svelte deleted file mode 100644 index d2014ef..0000000 --- a/site/src/routes/docs/_GuideContents.svelte +++ /dev/null @@ -1,136 +0,0 @@ - - - - - diff --git a/site/src/routes/docs/index.json.js b/site/src/routes/docs/index.json.js index d994b3c..006a185 100644 --- a/site/src/routes/docs/index.json.js +++ b/site/src/routes/docs/index.json.js @@ -1,11 +1,11 @@ import send from '@polka/send'; -import get_sections from './_sections.js'; +import generate_docs from '../../utils/generate_docs.js'; let json; export function get(req, res) { if (!json || process.env.NODE_ENV !== 'production') { - json = JSON.stringify(get_sections()); // TODO it errors if I send the non-stringified value + json = JSON.stringify(generate_docs('docs')); // TODO it errors if I send the non-stringified value } send(res, 200, json, { diff --git a/site/src/routes/docs/index.svelte b/site/src/routes/docs/index.svelte index 0f4be18..f321883 100644 --- a/site/src/routes/docs/index.svelte +++ b/site/src/routes/docs/index.svelte @@ -6,393 +6,17 @@ - - - API Docs • Svelte + Docs • Sapper - - - + + + -
- {#each sections as section} -
-

- - - - {section.metadata.title} - - - - -

- - {@html section.html} -
- {/each} -
- - + diff --git a/site/src/routes/migration/index.json.js b/site/src/routes/migration/index.json.js new file mode 100644 index 0000000..3fe415b --- /dev/null +++ b/site/src/routes/migration/index.json.js @@ -0,0 +1,14 @@ +import send from '@polka/send'; +import generate_docs from '../../utils/generate_docs.js'; + +let json; + +export function get(req, res) { + if (!json || process.env.NODE_ENV !== 'production') { + json = JSON.stringify(generate_docs('migration')); // TODO it errors if I send the non-stringified value + } + + send(res, 200, json, { + 'Content-Type': 'application/json' + }); +} diff --git a/site/src/routes/migration/index.svelte b/site/src/routes/migration/index.svelte new file mode 100644 index 0000000..6fa8603 --- /dev/null +++ b/site/src/routes/migration/index.svelte @@ -0,0 +1,22 @@ + + + + + + Migration • Sapper + + + + + + + diff --git a/site/src/routes/docs/_sections.js b/site/src/utils/generate_docs.js similarity index 89% rename from site/src/routes/docs/_sections.js rename to site/src/utils/generate_docs.js index 6fb7641..ae0e347 100644 --- a/site/src/routes/docs/_sections.js +++ b/site/src/utils/generate_docs.js @@ -1,11 +1,10 @@ +// TODO put this in site-kit? svelte.dev uses Prism instead of hljs import fs from 'fs'; import path from 'path'; -import { SLUG_SEPARATOR, SLUG_PRESERVE_UNICODE } from '../../../config'; +import { SLUG_SEPARATOR, SLUG_PRESERVE_UNICODE } from '../../config'; import { extract_frontmatter, extract_metadata, langs, link_renderer } from '@sveltejs/site-kit/utils/markdown.js'; import { make_session_slug_processor } from '@sveltejs/site-kit/utils/slug'; import marked from 'marked'; -// import PrismJS from 'prismjs'; -// import 'prismjs/components/prism-bash'; import hljs from 'highlight.js'; const escaped = { @@ -25,7 +24,7 @@ function unescape(str) { return String(str).replace(/&.+?;/g, match => unescaped[match] || match); } -const blockTypes = [ +const block_types = [ 'blockquote', 'html', 'heading', @@ -38,17 +37,17 @@ const blockTypes = [ 'tablecell' ]; -export default function() { +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/docs`) + .readdirSync(`content/${dir}`) .filter(file => file[0] !== '.' && path.extname(file) === '.md') .map(file => { - const markdown = fs.readFileSync(`content/docs/${file}`, 'utf-8'); + const markdown = fs.readFileSync(`content/${dir}/${file}`, 'utf-8'); const { content, metadata } = extract_frontmatter(markdown); @@ -131,12 +130,12 @@ export default function() { return ` 4 ? 'data-scrollignore' : ''}> - + ${text} `; }; - blockTypes.forEach(type => { + block_types.forEach(type => { const fn = renderer[type]; renderer[type] = function() { return fn.apply(this, arguments);