create-volt 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,28 @@ All notable changes to `create-volt` are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/), and this project adheres to
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.19.0] - 2026-06-29
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **`import-wxr` — WordPress importer.** `npx create-volt import-wxr <export.xml>`
|
|
11
|
+
converts a WordPress WXR export into markdown pages: published pages + posts →
|
|
12
|
+
`pages/<slug>.md` with front-matter (title, date, tags), Gutenberg block
|
|
13
|
+
comments stripped, body kept as HTML/markdown; drafts + attachments skipped;
|
|
14
|
+
slugs sanitized + de-duplicated. Flags: `--out <dir>`, `--drafts`, `--force`.
|
|
15
|
+
Zero-dep parser (WXR is a consistent format); unit-tested. Lowers the cost of
|
|
16
|
+
moving off WordPress. New `/docs/migrate`.
|
|
17
|
+
|
|
18
|
+
## [0.18.0] - 2026-06-29
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **Volt SSR** — `volt-ssr.js`, a tiny server-side renderer: render the same
|
|
22
|
+
`html` / `h()` markup and signal values to an HTML string in Node (`${values}`
|
|
23
|
+
escaped by default, `raw()` for trusted HTML) via `renderToString`. Ships in
|
|
24
|
+
every template, so a scaffolded app can be server-rendered for SEO + fast first
|
|
25
|
+
paint and hydrate with `volt.js` on the client. The Volt site itself is now
|
|
26
|
+
built with it — marketing pages as Volt components, docs as markdown rendered
|
|
27
|
+
with `raw()`, the whole page composed by `renderToString`.
|
|
28
|
+
|
|
7
29
|
## [0.17.0] - 2026-06-29
|
|
8
30
|
|
|
9
31
|
### Added
|
|
@@ -256,6 +278,8 @@ All notable changes to `create-volt` are documented here. The format follows
|
|
|
256
278
|
watching and full-page hot reload. Supports `--skip-install` and `--force`,
|
|
257
279
|
and auto-detects npm / pnpm / yarn / bun for the install step.
|
|
258
280
|
|
|
281
|
+
[0.19.0]: https://github.com/MIR-2025/volt/releases/tag/v0.19.0
|
|
282
|
+
[0.18.0]: https://github.com/MIR-2025/volt/releases/tag/v0.18.0
|
|
259
283
|
[0.17.0]: https://github.com/MIR-2025/volt/releases/tag/v0.17.0
|
|
260
284
|
[0.16.0]: https://github.com/MIR-2025/volt/releases/tag/v0.16.0
|
|
261
285
|
[0.15.1]: https://github.com/MIR-2025/volt/releases/tag/v0.15.1
|
package/index.js
CHANGED
|
@@ -61,12 +61,15 @@ const flags = new Set();
|
|
|
61
61
|
const positionals = [];
|
|
62
62
|
let portArg = null;
|
|
63
63
|
let templateArg = null;
|
|
64
|
+
let outArg = null;
|
|
64
65
|
for (let i = 0; i < argv.length; i++) {
|
|
65
66
|
const a = argv[i];
|
|
66
67
|
if (a === "--port") portArg = argv[++i];
|
|
67
68
|
else if (a.startsWith("--port=")) portArg = a.slice("--port=".length);
|
|
68
69
|
else if (a === "--template") templateArg = argv[++i];
|
|
69
70
|
else if (a.startsWith("--template=")) templateArg = a.slice("--template=".length);
|
|
71
|
+
else if (a === "--out") outArg = argv[++i];
|
|
72
|
+
else if (a.startsWith("--out=")) outArg = a.slice("--out=".length);
|
|
70
73
|
else if (a.startsWith("-")) flags.add(a);
|
|
71
74
|
else positionals.push(a);
|
|
72
75
|
}
|
|
@@ -132,6 +135,34 @@ if (positionals[0] === "config") {
|
|
|
132
135
|
process.exit(res.status ?? 0);
|
|
133
136
|
}
|
|
134
137
|
|
|
138
|
+
// --- `import-wxr` subcommand: import a WordPress export into markdown pages ---
|
|
139
|
+
if (positionals[0] === "import-wxr") {
|
|
140
|
+
const xmlPath = positionals[1];
|
|
141
|
+
if (!xmlPath) die(`Usage: ${cyan("create-volt import-wxr <export.xml>")} [--out pages] [--drafts] [--force]`);
|
|
142
|
+
if (!fs.existsSync(xmlPath)) die(`No such file: ${cyan(xmlPath)}`);
|
|
143
|
+
const outDir = path.resolve(outArg || "pages");
|
|
144
|
+
const { runImport } = await import("./lib/import-wxr.js");
|
|
145
|
+
const { imported, stats } = runImport(fs.readFileSync(xmlPath, "utf8"), { drafts: flags.has("--drafts") });
|
|
146
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
147
|
+
let written = 0;
|
|
148
|
+
let skippedExisting = 0;
|
|
149
|
+
for (const d of imported) {
|
|
150
|
+
const dest = path.join(outDir, d.filename);
|
|
151
|
+
if (fs.existsSync(dest) && !flags.has("--force")) {
|
|
152
|
+
skippedExisting++;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
fs.writeFileSync(dest, d.markdown);
|
|
156
|
+
written++;
|
|
157
|
+
console.log(" " + dim(path.relative(process.cwd(), dest)));
|
|
158
|
+
}
|
|
159
|
+
const types = Object.entries(stats.byType).map(([t, n]) => `${n} ${t}`).join(", ");
|
|
160
|
+
console.log(`\n${cyan(`✓ Imported ${written}`)} page(s) → ${outDir}`);
|
|
161
|
+
console.log(dim(` source: ${stats.total} items (${types}); skipped ${stats.draftsSkipped} draft(s), ${stats.otherTypeSkipped} non-page/post item(s)${skippedExisting ? `, ${skippedExisting} already-present (use --force)` : ""}.`));
|
|
162
|
+
console.log(dim(" Enable the pages add-on to serve them: npm run dev -- --edit"));
|
|
163
|
+
process.exit(0);
|
|
164
|
+
}
|
|
165
|
+
|
|
135
166
|
// --- `studio` subcommand: ephemeral, localhost-only data browser (server.js --studio) ---
|
|
136
167
|
if (positionals[0] === "studio") {
|
|
137
168
|
const cwd = process.cwd();
|
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// volt-ssr.js — server-side rendering for Volt. Renders the same html`` markup,
|
|
2
|
+
// h() elements, and signal values to an HTML string in Node (no DOM), so a Volt
|
|
3
|
+
// app can be fully server-rendered for SEO and hydrate interactive islands with
|
|
4
|
+
// volt.js on the client.
|
|
5
|
+
//
|
|
6
|
+
// import { html, h, raw, renderToString } from "./volt-ssr.js";
|
|
7
|
+
// renderToString(html`<p>${name}</p>`) // → "<p>Ada</p>" (name is escaped)
|
|
8
|
+
//
|
|
9
|
+
// Authoring matches the client: html`` interpolations render as escaped text;
|
|
10
|
+
// nest html``/h() nodes for structure; use raw() for trusted pre-built HTML.
|
|
11
|
+
|
|
12
|
+
const VOID = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
13
|
+
const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
14
|
+
|
|
15
|
+
// trusted, pre-rendered HTML — emitted verbatim. Use only for content you control.
|
|
16
|
+
export const raw = (s) => ({ __raw: String(s) });
|
|
17
|
+
|
|
18
|
+
// tagged-template markup; the literal chunks are trusted, ${values} are escaped.
|
|
19
|
+
export const html = (strings, ...values) => ({ __tpl: true, strings, values });
|
|
20
|
+
|
|
21
|
+
const isNode = (x) => x && typeof x === "object" && (x.__tpl || x.__raw || x.__el);
|
|
22
|
+
|
|
23
|
+
// hyperscript element: h(tag, props?, ...children)
|
|
24
|
+
export function h(tag, props, ...children) {
|
|
25
|
+
if (props === undefined || props === null || isNode(props) || Array.isArray(props) || typeof props !== "object") {
|
|
26
|
+
if (props !== undefined && props !== null) children.unshift(props);
|
|
27
|
+
props = {};
|
|
28
|
+
}
|
|
29
|
+
return { __el: true, tag, props, children };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const read = (v) => (typeof v === "function" ? v() : v); // resolve signals/thunks (once)
|
|
33
|
+
|
|
34
|
+
function attrs(props) {
|
|
35
|
+
let out = "";
|
|
36
|
+
for (const [k, rawVal] of Object.entries(props)) {
|
|
37
|
+
if (k === "children" || k.startsWith("on")) continue; // event handlers don't SSR
|
|
38
|
+
const v = read(rawVal);
|
|
39
|
+
if (v == null || v === false) continue;
|
|
40
|
+
const name = k === "className" ? "class" : k;
|
|
41
|
+
out += v === true ? ` ${name}` : ` ${name}="${esc(v)}"`;
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function renderToString(node) {
|
|
47
|
+
const v = read(node);
|
|
48
|
+
if (v == null || v === false || v === true) return "";
|
|
49
|
+
if (typeof v === "string" || typeof v === "number") return esc(v);
|
|
50
|
+
if (v.__raw != null) return v.__raw;
|
|
51
|
+
if (Array.isArray(v)) return v.map(renderToString).join("");
|
|
52
|
+
if (v.__tpl) {
|
|
53
|
+
let out = v.strings[0];
|
|
54
|
+
for (let i = 0; i < v.values.length; i++) out += renderToString(v.values[i]) + v.strings[i + 1];
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
if (v.__el) {
|
|
58
|
+
if (typeof v.tag === "function") return renderToString(v.tag({ ...v.props, children: v.children }));
|
|
59
|
+
const open = `<${v.tag}${attrs(v.props)}>`;
|
|
60
|
+
return VOID.has(v.tag) ? open : `${open}${v.children.map(renderToString).join("")}</${v.tag}>`;
|
|
61
|
+
}
|
|
62
|
+
return esc(String(v));
|
|
63
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// volt-ssr.js — server-side rendering for Volt. Renders the same html`` markup,
|
|
2
|
+
// h() elements, and signal values to an HTML string in Node (no DOM), so a Volt
|
|
3
|
+
// app can be fully server-rendered for SEO and hydrate interactive islands with
|
|
4
|
+
// volt.js on the client.
|
|
5
|
+
//
|
|
6
|
+
// import { html, h, raw, renderToString } from "./volt-ssr.js";
|
|
7
|
+
// renderToString(html`<p>${name}</p>`) // → "<p>Ada</p>" (name is escaped)
|
|
8
|
+
//
|
|
9
|
+
// Authoring matches the client: html`` interpolations render as escaped text;
|
|
10
|
+
// nest html``/h() nodes for structure; use raw() for trusted pre-built HTML.
|
|
11
|
+
|
|
12
|
+
const VOID = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
13
|
+
const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
14
|
+
|
|
15
|
+
// trusted, pre-rendered HTML — emitted verbatim. Use only for content you control.
|
|
16
|
+
export const raw = (s) => ({ __raw: String(s) });
|
|
17
|
+
|
|
18
|
+
// tagged-template markup; the literal chunks are trusted, ${values} are escaped.
|
|
19
|
+
export const html = (strings, ...values) => ({ __tpl: true, strings, values });
|
|
20
|
+
|
|
21
|
+
const isNode = (x) => x && typeof x === "object" && (x.__tpl || x.__raw || x.__el);
|
|
22
|
+
|
|
23
|
+
// hyperscript element: h(tag, props?, ...children)
|
|
24
|
+
export function h(tag, props, ...children) {
|
|
25
|
+
if (props === undefined || props === null || isNode(props) || Array.isArray(props) || typeof props !== "object") {
|
|
26
|
+
if (props !== undefined && props !== null) children.unshift(props);
|
|
27
|
+
props = {};
|
|
28
|
+
}
|
|
29
|
+
return { __el: true, tag, props, children };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const read = (v) => (typeof v === "function" ? v() : v); // resolve signals/thunks (once)
|
|
33
|
+
|
|
34
|
+
function attrs(props) {
|
|
35
|
+
let out = "";
|
|
36
|
+
for (const [k, rawVal] of Object.entries(props)) {
|
|
37
|
+
if (k === "children" || k.startsWith("on")) continue; // event handlers don't SSR
|
|
38
|
+
const v = read(rawVal);
|
|
39
|
+
if (v == null || v === false) continue;
|
|
40
|
+
const name = k === "className" ? "class" : k;
|
|
41
|
+
out += v === true ? ` ${name}` : ` ${name}="${esc(v)}"`;
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function renderToString(node) {
|
|
47
|
+
const v = read(node);
|
|
48
|
+
if (v == null || v === false || v === true) return "";
|
|
49
|
+
if (typeof v === "string" || typeof v === "number") return esc(v);
|
|
50
|
+
if (v.__raw != null) return v.__raw;
|
|
51
|
+
if (Array.isArray(v)) return v.map(renderToString).join("");
|
|
52
|
+
if (v.__tpl) {
|
|
53
|
+
let out = v.strings[0];
|
|
54
|
+
for (let i = 0; i < v.values.length; i++) out += renderToString(v.values[i]) + v.strings[i + 1];
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
if (v.__el) {
|
|
58
|
+
if (typeof v.tag === "function") return renderToString(v.tag({ ...v.props, children: v.children }));
|
|
59
|
+
const open = `<${v.tag}${attrs(v.props)}>`;
|
|
60
|
+
return VOID.has(v.tag) ? open : `${open}${v.children.map(renderToString).join("")}</${v.tag}>`;
|
|
61
|
+
}
|
|
62
|
+
return esc(String(v));
|
|
63
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// volt-ssr.js — server-side rendering for Volt. Renders the same html`` markup,
|
|
2
|
+
// h() elements, and signal values to an HTML string in Node (no DOM), so a Volt
|
|
3
|
+
// app can be fully server-rendered for SEO and hydrate interactive islands with
|
|
4
|
+
// volt.js on the client.
|
|
5
|
+
//
|
|
6
|
+
// import { html, h, raw, renderToString } from "./volt-ssr.js";
|
|
7
|
+
// renderToString(html`<p>${name}</p>`) // → "<p>Ada</p>" (name is escaped)
|
|
8
|
+
//
|
|
9
|
+
// Authoring matches the client: html`` interpolations render as escaped text;
|
|
10
|
+
// nest html``/h() nodes for structure; use raw() for trusted pre-built HTML.
|
|
11
|
+
|
|
12
|
+
const VOID = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
13
|
+
const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
14
|
+
|
|
15
|
+
// trusted, pre-rendered HTML — emitted verbatim. Use only for content you control.
|
|
16
|
+
export const raw = (s) => ({ __raw: String(s) });
|
|
17
|
+
|
|
18
|
+
// tagged-template markup; the literal chunks are trusted, ${values} are escaped.
|
|
19
|
+
export const html = (strings, ...values) => ({ __tpl: true, strings, values });
|
|
20
|
+
|
|
21
|
+
const isNode = (x) => x && typeof x === "object" && (x.__tpl || x.__raw || x.__el);
|
|
22
|
+
|
|
23
|
+
// hyperscript element: h(tag, props?, ...children)
|
|
24
|
+
export function h(tag, props, ...children) {
|
|
25
|
+
if (props === undefined || props === null || isNode(props) || Array.isArray(props) || typeof props !== "object") {
|
|
26
|
+
if (props !== undefined && props !== null) children.unshift(props);
|
|
27
|
+
props = {};
|
|
28
|
+
}
|
|
29
|
+
return { __el: true, tag, props, children };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const read = (v) => (typeof v === "function" ? v() : v); // resolve signals/thunks (once)
|
|
33
|
+
|
|
34
|
+
function attrs(props) {
|
|
35
|
+
let out = "";
|
|
36
|
+
for (const [k, rawVal] of Object.entries(props)) {
|
|
37
|
+
if (k === "children" || k.startsWith("on")) continue; // event handlers don't SSR
|
|
38
|
+
const v = read(rawVal);
|
|
39
|
+
if (v == null || v === false) continue;
|
|
40
|
+
const name = k === "className" ? "class" : k;
|
|
41
|
+
out += v === true ? ` ${name}` : ` ${name}="${esc(v)}"`;
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function renderToString(node) {
|
|
47
|
+
const v = read(node);
|
|
48
|
+
if (v == null || v === false || v === true) return "";
|
|
49
|
+
if (typeof v === "string" || typeof v === "number") return esc(v);
|
|
50
|
+
if (v.__raw != null) return v.__raw;
|
|
51
|
+
if (Array.isArray(v)) return v.map(renderToString).join("");
|
|
52
|
+
if (v.__tpl) {
|
|
53
|
+
let out = v.strings[0];
|
|
54
|
+
for (let i = 0; i < v.values.length; i++) out += renderToString(v.values[i]) + v.strings[i + 1];
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
if (v.__el) {
|
|
58
|
+
if (typeof v.tag === "function") return renderToString(v.tag({ ...v.props, children: v.children }));
|
|
59
|
+
const open = `<${v.tag}${attrs(v.props)}>`;
|
|
60
|
+
return VOID.has(v.tag) ? open : `${open}${v.children.map(renderToString).join("")}</${v.tag}>`;
|
|
61
|
+
}
|
|
62
|
+
return esc(String(v));
|
|
63
|
+
}
|