ssqch 0.11.0 → 0.13.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/bundled/completions/bash +67 -9
- package/bundled/completions/elvish +24 -4
- package/bundled/completions/fish +37 -25
- package/bundled/completions/powershell +26 -4
- package/bundled/completions/zsh +45 -10
- package/bundled/docs/agents.md +2 -2
- package/bundled/docs/build-summary.md +1 -1
- package/bundled/docs/comparing-builds.md +7 -4
- package/bundled/docs/configuring.md +7 -12
- package/bundled/docs/deploying.md +1 -1
- package/bundled/docs/field-guide.md +4 -4
- package/bundled/docs/github-pages.md +2 -1
- package/bundled/docs/index.md +1 -1
- package/bundled/docs/install.md +1 -1
- package/bundled/docs/known-gaps.md +1 -1
- package/bundled/docs/markdown.md +11 -13
- package/bundled/docs/nav.yml +6 -1
- package/bundled/docs/netlify.md +4 -2
- package/bundled/docs/patrol.md +48 -0
- package/bundled/docs/plugins.md +6 -4
- package/bundled/docs/robots.md +72 -0
- package/bundled/docs/seo.md +2 -38
- package/bundled/docs/serving-markdown.md +142 -0
- package/bundled/docs/template-languages.md +2 -1
- package/bundled/docs/templates.md +2 -1
- package/bundled/docs/trailheads/from-component-frameworks.md +9 -10
- package/bundled/docs/trailheads/from-hugo.md +5 -3
- package/bundled/docs/trailheads/from-jekyll.md +54 -13
- package/bundled/docs/trailheads/from-mkdocs.md +15 -12
- package/bundled/docs/trailheads/from-vitepress.md +142 -0
- package/bundled/docs/trailheads.md +5 -5
- package/bundled/docs/where-values-come-from.md +5 -5
- package/bundled/docs/writing-plugins.md +69 -0
- package/bundled/ssqch.d.ts +150 -34
- package/bundled/starter/engines/index.edge +1 -0
- package/bundled/starter/engines/index.ejs +1 -0
- package/bundled/starter/engines/index.hbs +1 -0
- package/bundled/starter/engines/index.liquid +1 -0
- package/bundled/starter/engines/layout.edge +7 -0
- package/bundled/starter/engines/layout.ejs +4 -0
- package/bundled/starter/engines/layout.hbs +4 -0
- package/bundled/starter/engines/layout.liquid +4 -0
- package/bundled/starter/src/_data/site.json +1 -0
- package/bundled/starter/src/_includes/layout.jinja +4 -0
- package/bundled/starter/src/index.jinja +1 -0
- package/bundled/starter/ssqch.config.js +14 -1
- package/bundled/starter-docs/engines/edge/base.edge +7 -0
- package/bundled/starter-docs/engines/edge/doc.edge +4 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
- package/bundled/starter-docs/src/_data/site.json +1 -0
- package/bundled/starter-docs/src/_includes/base.jinja +4 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
- package/bundled/starter-docs/src/assets/docs.css +4 -0
- package/bundled/starter-docs/src/assets/docs.js +17 -0
- package/bundled/starter-docs/ssqch.config.js +14 -1
- package/lib/assets.js +13 -11
- package/lib/chunk-25WERNDD.js +112 -0
- package/lib/{chunk-H5K2ZE7B.js → chunk-2BJFGKOE.js} +13 -5
- package/lib/chunk-2FKYWYAB.js +268 -0
- package/lib/{chunk-LJOURBYT.js → chunk-3ZTRIO6O.js} +21 -19
- package/lib/{chunk-IOBC665M.js → chunk-4AZFCSGJ.js} +5 -3
- package/lib/{chunk-HWW5NCVJ.js → chunk-4Q6WMTER.js} +1 -1
- package/lib/{chunk-V2FSMOFX.js → chunk-55WXDGO4.js} +3 -3
- package/lib/{chunk-ZR3JYLFB.js → chunk-6FY77I4M.js} +331 -58
- package/lib/{chunk-JC54PHIT.js → chunk-6OUCRDYI.js} +514 -141
- package/lib/{chunk-ERAIEV3O.js → chunk-6U5VIQVY.js} +9 -7
- package/lib/{chunk-Z5OP43HU.js → chunk-7U5GWTEH.js} +455 -94
- package/lib/{chunk-CMJ7X5WW.js → chunk-AIJNG6MJ.js} +3 -2
- package/lib/{chunk-3K237XAX.js → chunk-C2Q7JKFI.js} +12 -10
- package/lib/{chunk-GS5B3CBW.js → chunk-DDV6JEC2.js} +1 -1
- package/lib/{chunk-A75EVUJX.js → chunk-DFJFHULZ.js} +47 -20
- package/lib/{chunk-KZZS4W2V.js → chunk-ENWDM2RW.js} +45 -42
- package/lib/{chunk-I3HYKEEW.js → chunk-ER72RPD6.js} +3 -3
- package/lib/chunk-F3JPNFCZ.js +23 -0
- package/lib/{chunk-B5E27PLU.js → chunk-FENJHLNM.js} +6 -3
- package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
- package/lib/{chunk-KCF2Z6N7.js → chunk-FQZDUDFK.js} +5 -3
- package/lib/{chunk-GJNIQAIH.js → chunk-GSNRAGKQ.js} +13 -6
- package/lib/{chunk-443ZQLVX.js → chunk-GU7BBYWB.js} +5 -4
- package/lib/{chunk-X2GAVYV2.js → chunk-HDKU6LRI.js} +110 -748
- package/lib/chunk-J3C2LEW7.js +121 -0
- package/lib/{chunk-XS4EJSEK.js → chunk-K5WZ2VYK.js} +7 -5
- package/lib/{chunk-3HZZY3Y7.js → chunk-OOKBXQAY.js} +7 -6
- package/lib/chunk-P2WS4RM4.js +707 -0
- package/lib/{chunk-RBNPBTDP.js → chunk-SNQOHNXE.js} +1 -1
- package/lib/{chunk-HFSWUTXX.js → chunk-SPIFZBIW.js} +1 -1
- package/lib/{chunk-QLUTNR37.js → chunk-T5IUI7W7.js} +12 -11
- package/lib/{chunk-ZINLHOX4.js → chunk-TGSVSG2G.js} +3 -2
- package/lib/{chunk-2L3HR67O.js → chunk-U2KEMVXO.js} +24 -16
- package/lib/{chunk-RYIWYWRQ.js → chunk-UHRBPZ4A.js} +7 -5
- package/lib/{chunk-2QTJTEBV.js → chunk-ULCT3PAV.js} +1 -1
- package/lib/{chunk-FCM3NYFR.js → chunk-UZNUS7RP.js} +12 -9
- package/lib/{chunk-GLJQ4C76.js → chunk-V3G2QGL3.js} +13 -106
- package/lib/{chunk-Z44IAMNG.js → chunk-VILOEVK7.js} +60 -28
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/{chunk-5ELAUHRL.js → chunk-WGAIE3DD.js} +23 -19
- package/lib/{chunk-OQGXZYZS.js → chunk-WUCRAV36.js} +13 -7
- package/lib/{chunk-RZYAIX2R.js → chunk-XYAWJTHM.js} +11 -10
- package/lib/{chunk-OSBEH67S.js → chunk-YA23NDMW.js} +5 -3
- package/lib/{chunk-AIMEXBTK.js → chunk-YNJNMQWU.js} +37 -142
- package/lib/{chunk-QJ5ZFTML.js → chunk-ZMG25MXF.js} +20 -18
- package/lib/cli.js +72 -35
- package/lib/elements.js +13 -11
- package/lib/from-hugo.js +36 -0
- package/lib/from-jekyll.js +41 -0
- package/lib/from-mkdocs.js +49 -0
- package/lib/from-vitepress.js +49 -0
- package/lib/image.js +12 -11
- package/lib/links.js +13 -11
- package/lib/llms.js +613 -0
- package/lib/minify.js +14 -12
- package/lib/redirects.js +13 -11
- package/lib/robots.js +87 -0
- package/lib/rss.js +24 -13
- package/lib/sass.js +12 -11
- package/lib/sitemap.js +23 -18
- package/lib/ssqch.js +6 -5
- package/lib/vue.js +400 -0
- package/package.json +29 -1
- package/types/from-hugo.d.ts +5 -0
- package/types/from-jekyll.d.ts +11 -0
- package/types/from-mkdocs.d.ts +11 -0
- package/types/from-vitepress.d.ts +5 -0
- package/types/index.d.ts +51 -31
- package/types/llms.d.ts +27 -0
- package/types/robots.d.ts +13 -0
- package/types/sass.d.ts +1 -1
- package/types/sitemap.d.ts +2 -2
- package/types/vue.d.ts +17 -0
- package/wasm/markdown.wasm +0 -0
- package/lib/chunk-RVXGUMFI.js +0 -21
- /package/lib/{chunk-ZR3JYLFB.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
- /package/lib/{chunk-AIMEXBTK.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
2
|
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
baselineTime
|
|
5
|
-
} from "./chunk-H5K2ZE7B.js";
|
|
6
3
|
import {
|
|
7
4
|
rustRegExp
|
|
8
5
|
} from "./chunk-3GYLOC6Y.js";
|
|
@@ -10,45 +7,54 @@ import {
|
|
|
10
7
|
jinjaFilters,
|
|
11
8
|
readMkdocsYaml,
|
|
12
9
|
require_liquid_node
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-HWW5NCVJ.js";
|
|
10
|
+
} from "./chunk-YA23NDMW.js";
|
|
15
11
|
import {
|
|
16
12
|
BUILTIN_FILTERS
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import
|
|
19
|
-
|
|
13
|
+
} from "./chunk-V3G2QGL3.js";
|
|
14
|
+
import {
|
|
15
|
+
baselineTime
|
|
16
|
+
} from "./chunk-2BJFGKOE.js";
|
|
17
|
+
import "./chunk-4Q6WMTER.js";
|
|
18
|
+
import "./chunk-HDKU6LRI.js";
|
|
19
|
+
import "./chunk-P2WS4RM4.js";
|
|
20
|
+
import "./chunk-UHRBPZ4A.js";
|
|
21
|
+
import "./chunk-25WERNDD.js";
|
|
20
22
|
import {
|
|
21
23
|
findConfig
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-VILOEVK7.js";
|
|
25
|
+
import "./chunk-ULCT3PAV.js";
|
|
26
|
+
import "./chunk-6U5VIQVY.js";
|
|
25
27
|
import {
|
|
26
28
|
VERSION
|
|
27
29
|
} from "./chunk-AD3HAW3W.js";
|
|
28
30
|
import "./chunk-YCOTX2VM.js";
|
|
29
|
-
import
|
|
31
|
+
import {
|
|
32
|
+
CONFIG_FILES
|
|
33
|
+
} from "./chunk-DDV6JEC2.js";
|
|
30
34
|
import {
|
|
31
35
|
require_nunjucks
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
36
|
+
} from "./chunk-6OUCRDYI.js";
|
|
37
|
+
import "./chunk-SPIFZBIW.js";
|
|
34
38
|
import "./chunk-FVZ5JBRI.js";
|
|
35
|
-
import "./chunk-
|
|
39
|
+
import "./chunk-FJML7INB.js";
|
|
36
40
|
import {
|
|
37
41
|
importFile
|
|
38
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-4AZFCSGJ.js";
|
|
39
43
|
import "./chunk-CMUWRPSQ.js";
|
|
40
44
|
import {
|
|
41
45
|
TABLE,
|
|
42
46
|
TomlError,
|
|
43
|
-
compareText,
|
|
44
|
-
isDir,
|
|
45
|
-
isFile,
|
|
46
47
|
isPlainObject,
|
|
47
48
|
parseYaml,
|
|
48
49
|
readToml,
|
|
49
50
|
red,
|
|
50
51
|
tomlReason
|
|
51
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-YNJNMQWU.js";
|
|
53
|
+
import {
|
|
54
|
+
compareText,
|
|
55
|
+
isDir,
|
|
56
|
+
isFile
|
|
57
|
+
} from "./chunk-VJWQSYEG.js";
|
|
52
58
|
import {
|
|
53
59
|
__toESM
|
|
54
60
|
} from "./chunk-I3PS26CI.js";
|
|
@@ -299,7 +305,7 @@ async function runScout(dir, options) {
|
|
|
299
305
|
if (found.length > 1) fail(`more than one generator's files are in ${dir} (${found.map(([g, file]) => `${GENERATORS[g].name}: ${file}`).join("; ")}): choose with --from`);
|
|
300
306
|
[id, how] = found[0];
|
|
301
307
|
}
|
|
302
|
-
const plan = id === "eleventy" ? eleventy(dir) : id === "jekyll" ? jekyll(dir) : id === "zola" ? zola(dir) : id === "hugo" ? hugo(dir) : id === "mkdocs" ? mkdocs(dir) : other(dir, id);
|
|
308
|
+
const plan = id === "eleventy" ? eleventy(dir) : id === "jekyll" ? jekyll(dir) : id === "zola" ? zola(dir) : id === "hugo" ? hugo(dir) : id === "mkdocs" ? mkdocs(dir) : id === "vitepress" ? vitepress(dir) : other(dir, id);
|
|
303
309
|
const report = scoutReport(plan, dir, id, how, await siteConfig(dir));
|
|
304
310
|
if (options.compare !== void 0) report.compare = compareBuilds(dir, options.compare);
|
|
305
311
|
if (options.writeDraft) {
|
|
@@ -319,13 +325,88 @@ async function runScout(dir, options) {
|
|
|
319
325
|
async function siteConfig(dir) {
|
|
320
326
|
const file = findConfig(dir);
|
|
321
327
|
if (!file) return {};
|
|
328
|
+
const emitWarning = process.emitWarning;
|
|
329
|
+
process.emitWarning = ((warning, ...rest) => {
|
|
330
|
+
const options = rest[0];
|
|
331
|
+
const code = warning instanceof Error ? warning.code : options !== null && typeof options === "object" ? options.code : rest[1];
|
|
332
|
+
if (code === "MODULE_TYPELESS_PACKAGE_JSON") return;
|
|
333
|
+
return emitWarning.call(process, warning, ...rest);
|
|
334
|
+
});
|
|
322
335
|
try {
|
|
323
336
|
const value = (await importFile(file)).default;
|
|
324
|
-
|
|
337
|
+
const source = readUtf8(file);
|
|
338
|
+
return isPlainObject(value) ? { config: value, dir, ...source === void 0 ? {} : { source } } : { error: `${path.basename(file)}'s default export isn't an object` };
|
|
325
339
|
} catch (e) {
|
|
326
340
|
return { error: `${path.basename(file)}: ${e instanceof Error ? e.message.split("\n")[0] : String(e)}` };
|
|
341
|
+
} finally {
|
|
342
|
+
process.emitWarning = emitWarning;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function definedIn(site, defines) {
|
|
346
|
+
const config = site.config;
|
|
347
|
+
if (!config) return void 0;
|
|
348
|
+
const code = site.source === void 0 ? "" : blankComments(site.source);
|
|
349
|
+
for (const want of defines) {
|
|
350
|
+
if (want.startsWith("file:")) {
|
|
351
|
+
if (site.dir === void 0) continue;
|
|
352
|
+
const rel = want.slice("file:".length);
|
|
353
|
+
const folder = path.join(site.dir, ...path.posix.dirname(rel).split("/"));
|
|
354
|
+
const base = path.posix.basename(rel);
|
|
355
|
+
let names = [];
|
|
356
|
+
try {
|
|
357
|
+
names = fs.readdirSync(folder);
|
|
358
|
+
} catch {
|
|
359
|
+
}
|
|
360
|
+
const found = base.endsWith(".*") ? names.find((n) => n.startsWith(base.slice(0, -1)) && n.length > base.length - 1) : names.find((n) => n === base);
|
|
361
|
+
if (found !== void 0) return path.posix.join(path.posix.dirname(rel), found);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (want.startsWith("reads:")) {
|
|
365
|
+
if (site.dir === void 0) continue;
|
|
366
|
+
const [, folder, word] = /^reads:([^:]+):(.*)$/.exec(want) ?? [];
|
|
367
|
+
if (folder === void 0) continue;
|
|
368
|
+
const root = path.join(site.dir, ...folder.split("/"));
|
|
369
|
+
const files = (() => {
|
|
370
|
+
try {
|
|
371
|
+
return fs.readdirSync(root, { recursive: true }).map(String);
|
|
372
|
+
} catch {
|
|
373
|
+
return [];
|
|
374
|
+
}
|
|
375
|
+
})();
|
|
376
|
+
const hit = files.find((f) => {
|
|
377
|
+
const full = path.join(root, f);
|
|
378
|
+
try {
|
|
379
|
+
return fs.statSync(full).isFile() && fs.readFileSync(full, "utf8").includes(word);
|
|
380
|
+
} catch {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
if (hit !== void 0) return `${folder}/${hit.split(path.sep).join("/")}`;
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (want.startsWith("has:")) {
|
|
388
|
+
const [, at, value] = /^has:([^:]+):(.*)$/.exec(want) ?? [];
|
|
389
|
+
let list = config;
|
|
390
|
+
for (const key of (at ?? "").split(".")) list = isPlainObject(list) ? list[key] : void 0;
|
|
391
|
+
if (Array.isArray(list) && list.includes(value)) return `${at}: "${value}"`;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (want.startsWith("plugin:")) {
|
|
395
|
+
const name = want.slice("plugin:".length);
|
|
396
|
+
const plugins = Array.isArray(config.plugins) ? config.plugins.flat(Infinity) : [];
|
|
397
|
+
if (plugins.some((p) => isPlainObject(p) && p.name === name)) return name;
|
|
398
|
+
} else if (want.startsWith("import:")) {
|
|
399
|
+
const pkg = want.slice("import:".length);
|
|
400
|
+
for (const m of code.matchAll(IMPORTED)) if (m[1] === pkg || m[1].startsWith(`${pkg}/`)) return `import "${pkg}"`;
|
|
401
|
+
} else {
|
|
402
|
+
let at = config;
|
|
403
|
+
for (const key of want.split(".")) at = isPlainObject(at) && Object.hasOwn(at, key) ? at[key] : void 0;
|
|
404
|
+
if (at !== void 0 && at !== null) return want;
|
|
405
|
+
}
|
|
327
406
|
}
|
|
407
|
+
return void 0;
|
|
328
408
|
}
|
|
409
|
+
var IMPORTED = /(?:\brequire\(\s*|\bimport\s*\(\s*|\bfrom\s+|^\s*import\s+)["']([^"']+)["']/gm;
|
|
329
410
|
function setIn(config, option) {
|
|
330
411
|
let want;
|
|
331
412
|
try {
|
|
@@ -357,14 +438,16 @@ function scoutReport(plan, dir, id, how, site = {}) {
|
|
|
357
438
|
files: meta?.files ?? null,
|
|
358
439
|
option: meta?.option ?? null,
|
|
359
440
|
docs: meta?.docs ?? null,
|
|
360
|
-
order
|
|
361
|
-
|
|
441
|
+
order,
|
|
442
|
+
defines: meta?.defines
|
|
443
|
+
})).sort((a, b) => (b.files ?? -1) - (a.files ?? -1) || a.order - b.order);
|
|
362
444
|
const done = [];
|
|
363
|
-
const todo =
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
445
|
+
const todo = [];
|
|
446
|
+
for (const { order: _, defines, ...t } of all) {
|
|
447
|
+
const by = t.status === "option" && t.option && site.config && setIn(site.config, t.option) ? t.option : defines ? definedIn(site, defines) : void 0;
|
|
448
|
+
if (by === void 0) todo.push(t);
|
|
449
|
+
else done.push({ at: t.at, what: t.what, code: t.code, option: by });
|
|
450
|
+
}
|
|
368
451
|
return {
|
|
369
452
|
dir,
|
|
370
453
|
generator: id,
|
|
@@ -395,14 +478,49 @@ function referenceBuild(dir, id) {
|
|
|
395
478
|
const netlifyCommand = /^\s*command\s*=\s*"([^"]+)"/m.exec(netlify)?.[1];
|
|
396
479
|
const netlifyPublish = /^\s*publish\s*=\s*"([^"]+)"/m.exec(netlify)?.[1];
|
|
397
480
|
let scripts = {};
|
|
481
|
+
let pkgJson = {};
|
|
398
482
|
try {
|
|
399
|
-
|
|
483
|
+
pkgJson = JSON.parse(readUtf8(path.join(dir, "package.json")) ?? "{}");
|
|
484
|
+
scripts = pkgJson.scripts ?? {};
|
|
400
485
|
} catch {
|
|
401
486
|
}
|
|
487
|
+
const pm = packageManager(dir, pkgJson);
|
|
402
488
|
const words = { eleventy: /\beleventy\b/, jekyll: /\bjekyll\b/, hugo: /\bhugo\b/, zola: /\bzola\b/, mkdocs: /\bmkdocs\b/, docusaurus: /\bdocusaurus\b/, astro: /\bastro\b/, vitepress: /\bvitepress\b/, hexo: /\bhexo\b/ };
|
|
489
|
+
const watching = /\b(?:watch|serve|start|dev|debug)\b|--(?:watch|serve)\b/;
|
|
490
|
+
const runsIt = (script) => words[id].test(script) || /\bssqch\s+build\b/.test(script);
|
|
491
|
+
const named = [...typeof scripts.build === "string" ? ["build"] : [], ...Object.keys(scripts).filter((k) => k !== "build")].find((k) => typeof scripts[k] === "string" && runsIt(scripts[k]) && !watching.test(k) && !watching.test(scripts[k]));
|
|
403
492
|
if (netlifyCommand && words[id].test(netlifyCommand)) command = netlifyCommand;
|
|
404
|
-
else if (
|
|
493
|
+
else if (named !== void 0) {
|
|
494
|
+
const script = scripts[named];
|
|
495
|
+
const parts = script.split(/\s*&&?\s*/).filter((p) => p !== "");
|
|
496
|
+
const own = /\bssqch\s+build\b/.test(script);
|
|
497
|
+
if (parts.length > 1) command = parts.map((p) => /\bssqch\s+build\b/.test(p) ? g.build : p).join(" && ");
|
|
498
|
+
else if (!own) command = `${pm} run ${named}`;
|
|
499
|
+
}
|
|
405
500
|
if (netlifyPublish && command === netlifyCommand) output = netlifyPublish.replace(/^\.\//, "").replace(/\/$/, "");
|
|
501
|
+
if (id === "eleventy") {
|
|
502
|
+
const config = ELEVENTY_CONFIGS.find((name) => isFile(path.join(dir, name)));
|
|
503
|
+
const set = config === void 0 ? void 0 : setting(blankComments(readUtf8(path.join(dir, config)) ?? ""), "output");
|
|
504
|
+
if (set !== void 0) output = set.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
505
|
+
if (["gulpfile.js", "gulpfile.mjs", "gulpfile.cjs"].some((f) => isFile(path.join(dir, f))) && !/\bgulp\b/.test(command)) command += " && npx gulp";
|
|
506
|
+
}
|
|
507
|
+
if (id === "vitepress") {
|
|
508
|
+
const config = VITEPRESS_CONFIGS.find((f) => isFile(path.join(dir, f)));
|
|
509
|
+
const root = config?.startsWith("docs/") ? "docs/" : "";
|
|
510
|
+
const outDir = config === void 0 ? void 0 : /\boutDir\s*:\s*["'`]([^"'`]+)["'`]/.exec(blankComments(readUtf8(path.join(dir, config)) ?? ""))?.[1];
|
|
511
|
+
output = outDir !== void 0 ? path.posix.normalize(`${root}${outDir.replace(/^\.\//, "")}`).replace(/\/+$/, "") : `${root}.vitepress/dist`;
|
|
512
|
+
}
|
|
513
|
+
if (["eleventy", "docusaurus", "astro", "vitepress", "hexo"].includes(id)) {
|
|
514
|
+
let engines;
|
|
515
|
+
try {
|
|
516
|
+
engines = JSON.parse(readUtf8(path.join(dir, "package.json")) ?? "{}").engines?.node;
|
|
517
|
+
} catch {
|
|
518
|
+
}
|
|
519
|
+
const pinned = [[".nvmrc", readUtf8(path.join(dir, ".nvmrc"))], [".node-version", readUtf8(path.join(dir, ".node-version"))], ["netlify.toml", /\bNODE_VERSION\s*=\s*"([^"]+)"/.exec(netlify)?.[1]], ["package.json's engines", typeof engines === "string" ? engines : void 0]];
|
|
520
|
+
const found = pinned.find(([, v]) => v !== void 0 && /\d/.test(v) && !/^\s*>|\|\|/.test(v));
|
|
521
|
+
const major = found === void 0 ? void 0 : Number(/(\d+)/.exec(found[1])[1]);
|
|
522
|
+
if (found && major !== void 0 && major < 22) needs.push(`The site asks for Node ${trim(found[1]).replace(/^v/, "")} (${found[0]}), and ssqch needs 22.18 or later. Try the reference build on ssqch's Node first (old generators often build the same there); if it fails, give baseline the command with that Node (\`ssqch baseline "npx -y -p node@${major} -c '${command.replace(/'/g, "")}'"\`)`);
|
|
523
|
+
}
|
|
406
524
|
if (id === "mkdocs") {
|
|
407
525
|
const requirements = ["requirements.txt", "requirements-docs.txt", "docs/requirements.txt", "requirements/docs.txt"].filter((f) => isFile(path.join(dir, f)));
|
|
408
526
|
const venv = [".venv", "venv"].find((v) => isFile(path.join(dir, v, "bin", "mkdocs")) || isFile(path.join(dir, v, "Scripts", "mkdocs.exe")));
|
|
@@ -422,6 +540,11 @@ function referenceBuild(dir, id) {
|
|
|
422
540
|
if (/\btailwindcss\b/.test(readUtf8(path.join(dir, "package.json")) ?? "") && !["eleventy", "astro", "docusaurus", "vitepress"].includes(id)) needs.push("Node and `npm install` first: the site builds its CSS with Tailwind");
|
|
423
541
|
return { command, output, needs };
|
|
424
542
|
}
|
|
543
|
+
function doneList(done) {
|
|
544
|
+
const names = [...new Set(done.map((d) => d.option))];
|
|
545
|
+
const shown = names.slice(0, 8).map((o) => `\`${o}\``).join(", ");
|
|
546
|
+
return names.length > 8 ? `${shown} and ${names.length - 8} more` : shown;
|
|
547
|
+
}
|
|
425
548
|
function scoutText(report, options) {
|
|
426
549
|
let out = `Scouting the ${report.name} site in ${report.dir} (found ${report.detectedBy === "--from" ? "with --from" : report.detectedBy})${report.underWay ? ": a move under way, with an ssqch.config.js" : ""}
|
|
427
550
|
`;
|
|
@@ -429,7 +552,7 @@ function scoutText(report, options) {
|
|
|
429
552
|
if (report.todo.length) out += `
|
|
430
553
|
${report.todo.length} to do${summary.pages !== null ? ` across ${summary.pages} ${summary.pages === 1 ? "page" : "pages"}` : ""}: ${[[summary.ssqch, "ssqch does"], [summary.option, "an option does (the draft turns it on)"], [summary.notYet, "not in ssqch yet"], [summary.site, "the site's own code to port"]].filter(([n]) => n).map(([n, what]) => `${n} ${what}`).join(", ")}.
|
|
431
554
|
`;
|
|
432
|
-
if (report.done.length) out += `${report.todo.length ? "" : "\n"}${report.done.length} done already: ssqch.config.js
|
|
555
|
+
if (report.done.length) out += `${report.todo.length ? "" : "\n"}${report.done.length} done already: ssqch.config.js has ${doneList(report.done)}.
|
|
433
556
|
`;
|
|
434
557
|
if (report.configError) out += `
|
|
435
558
|
Couldn't read the site's config, so nothing counts as done yet: ${report.configError}
|
|
@@ -780,7 +903,7 @@ function eleventy(dir) {
|
|
|
780
903
|
const inInput = (rel) => input === "" || input === "." || rel === input || rel.startsWith(`${input}/`);
|
|
781
904
|
if (major !== void 0 && major < 2) keep.push("eleventy.generator");
|
|
782
905
|
if (readsNavigation) {
|
|
783
|
-
plan.byHand.push([".", "`eleventyNavigation` front matter was left as it is, because templates call the `eleventyNavigation` filter, which reads it. To keep that filter, define it with the package's own function: `import navigation from \"@11ty/eleventy-navigation/eleventy-navigation.js\"`, then `filters: { eleventyNavigation: (pages, key) => navigation.findNavigationEntries(pages, key) }`. To move to ssqch's navigation instead (`pagesTree`), rename it to `nav` (`ssqch docs nav`)"]);
|
|
906
|
+
plan.byHand.push([".", "`eleventyNavigation` front matter was left as it is, because templates call the `eleventyNavigation` filter, which reads it. To keep that filter, define it with the package's own function: `import navigation from \"@11ty/eleventy-navigation/eleventy-navigation.js\"`, then `filters: { eleventyNavigation: (pages, key) => navigation.findNavigationEntries(pages, key) }`. To move to ssqch's navigation instead (`pagesTree`), rename it to `nav` (`ssqch docs nav`)", { defines: ["filters.eleventyNavigation"] }]);
|
|
784
907
|
} else {
|
|
785
908
|
const navPages = entries.filter((e) => e.isFile && isTemplate(e.name) && /^eleventyNavigation\s*:/m.test(readUtf8(e.abs) ?? "")).map((e) => e.rel);
|
|
786
909
|
if (navPages.length) plan.byHand.push([navPages[0], `\`eleventyNavigation\` front matter (in ${navPages.length} ${navPages.length === 1 ? "page" : "pages"}; this is the first): ssqch's navigation reads \`nav\`, with the same \`key\`, \`parent\`, \`order\` and \`title\`, as a tree from \`pagesTree(collections.all)\` (\`ssqch docs pagesTree\`). Rename it when the templates move to that; until then nothing reads it`]);
|
|
@@ -799,7 +922,7 @@ function eleventy(dir) {
|
|
|
799
922
|
continue;
|
|
800
923
|
}
|
|
801
924
|
const template = TEMPLATE_EXTENSIONS.includes(ext);
|
|
802
|
-
const data = DATA_FILE.test(name) || ["json", "yaml", "yml"].includes(ext) && !name.startsWith("package");
|
|
925
|
+
const data = inInput(rel) && (DATA_FILE.test(name) || ["json", "yaml", "yml"].includes(ext) && !name.startsWith("package"));
|
|
803
926
|
if (!template && !data) continue;
|
|
804
927
|
const text = readUtf8(entry.abs);
|
|
805
928
|
if (text === void 0) continue;
|
|
@@ -893,7 +1016,7 @@ function outsideCode(text, markdown, change) {
|
|
|
893
1016
|
if (!markdown) return change(text);
|
|
894
1017
|
let out = "";
|
|
895
1018
|
let fence;
|
|
896
|
-
let
|
|
1019
|
+
let prose2 = "";
|
|
897
1020
|
for (let start = 0; start < text.length; ) {
|
|
898
1021
|
const nl = text.indexOf("\n", start);
|
|
899
1022
|
const end = nl === -1 ? text.length : nl + 1;
|
|
@@ -902,8 +1025,8 @@ function outsideCode(text, markdown, change) {
|
|
|
902
1025
|
const trimmed = trimStart(line);
|
|
903
1026
|
const marker = trimmed.startsWith("```") ? "```" : trimmed.startsWith("~~~") ? "~~~" : void 0;
|
|
904
1027
|
if (fence === void 0 && marker !== void 0) {
|
|
905
|
-
out += changeProse(
|
|
906
|
-
|
|
1028
|
+
out += changeProse(prose2, change);
|
|
1029
|
+
prose2 = "";
|
|
907
1030
|
fence = marker;
|
|
908
1031
|
out += line;
|
|
909
1032
|
} else if (fence !== void 0 && marker === fence) {
|
|
@@ -912,13 +1035,13 @@ function outsideCode(text, markdown, change) {
|
|
|
912
1035
|
} else if (fence !== void 0) {
|
|
913
1036
|
out += line;
|
|
914
1037
|
} else {
|
|
915
|
-
|
|
1038
|
+
prose2 += line;
|
|
916
1039
|
}
|
|
917
1040
|
}
|
|
918
|
-
return out + changeProse(
|
|
1041
|
+
return out + changeProse(prose2, change);
|
|
919
1042
|
}
|
|
920
|
-
function changeProse(
|
|
921
|
-
return
|
|
1043
|
+
function changeProse(prose2, change) {
|
|
1044
|
+
return prose2.split("`").map((part, i) => i % 2 === 1 ? part : change(part)).join("`");
|
|
922
1045
|
}
|
|
923
1046
|
function unwrapUrlLiterals(text) {
|
|
924
1047
|
let literals = 0;
|
|
@@ -1007,7 +1130,8 @@ function undefinedFilters(entries, config, readsNavigation, plan) {
|
|
|
1007
1130
|
const where = use.templates.size === 1 ? "" : ` (in ${use.templates.size} templates; this is the first)`;
|
|
1008
1131
|
const eleventy2 = Object.hasOwn(ELEVENTY_FILTERS, name) ? ELEVENTY_FILTERS[name] : void 0;
|
|
1009
1132
|
if (eleventy2?.port) ports.push([name, eleventy2.port]);
|
|
1010
|
-
|
|
1133
|
+
const plugin = eleventy2?.say.includes("rssPlugin()") ? ["plugin:ssqch/rss"] : [];
|
|
1134
|
+
plan.byHand.push([use.first, eleventy2 ? `\`${name}\`${where}: ${eleventy2.say}` : `\`${name}\`${where} is a filter or shortcode nothing defines: not the template language, not ssqch, not the Eleventy config. A plugin's, or one a helper module adds? Port it to \`filters\``, { defines: [`filters.${name}`, ...plugin] }]);
|
|
1011
1135
|
}
|
|
1012
1136
|
return ports;
|
|
1013
1137
|
}
|
|
@@ -1043,7 +1167,7 @@ function modulesUsingEleventy(entries, config, plan) {
|
|
|
1043
1167
|
"@11ty/eleventy-fetch": '`fetch(url, { cache: "1d" })`, from "ssqch" in a data file: it keeps a copy in `.cache/ssqch/fetch/` as eleventy-fetch kept one in `.cache`'
|
|
1044
1168
|
};
|
|
1045
1169
|
for (const entry of entries) {
|
|
1046
|
-
if (!entry.isFile || entry.rel === config || !/\.(?:[cm]?js|[cm]?ts)$/.test(entry.name)) continue;
|
|
1170
|
+
if (!entry.isFile || entry.rel === config || CONFIG_FILES.includes(entry.rel) || !/\.(?:[cm]?js|[cm]?ts)$/.test(entry.name)) continue;
|
|
1047
1171
|
const text = readUtf8(entry.abs);
|
|
1048
1172
|
if (text === void 0 || !text.includes("eleventy") && !text.includes("markdown-it")) continue;
|
|
1049
1173
|
const code = blankComments(text);
|
|
@@ -1130,6 +1254,31 @@ function eleventyMajor(dir) {
|
|
|
1130
1254
|
}
|
|
1131
1255
|
return void 0;
|
|
1132
1256
|
}
|
|
1257
|
+
function packageDefines(pkg) {
|
|
1258
|
+
const kept = `import:${pkg}`;
|
|
1259
|
+
switch (pkg) {
|
|
1260
|
+
case "@11ty/eleventy-img":
|
|
1261
|
+
return ["plugin:ssqch/image", kept];
|
|
1262
|
+
case "@11ty/eleventy-plugin-rss":
|
|
1263
|
+
return ["plugin:ssqch/rss", kept];
|
|
1264
|
+
case "@11ty/eleventy-plugin-syntaxhighlight":
|
|
1265
|
+
return ["markdown.highlight", "engines.md", kept];
|
|
1266
|
+
case "@11ty/eleventy-navigation":
|
|
1267
|
+
return ["filters.eleventyNavigation", kept];
|
|
1268
|
+
case "@11ty/eleventy-plugin-bundle":
|
|
1269
|
+
case "@11ty/eleventy-plugin-webc":
|
|
1270
|
+
case "@11ty/is-land":
|
|
1271
|
+
return ["plugin:ssqch/elements", kept];
|
|
1272
|
+
case "markdown-it-anchor":
|
|
1273
|
+
return ["markdown.headingIds", "engines.md", kept];
|
|
1274
|
+
case "markdown-it-footnote":
|
|
1275
|
+
return ["markdown.footnotes", "engines.md", kept];
|
|
1276
|
+
case "markdown-it-implicit-figures":
|
|
1277
|
+
return ["markdown.figures", "engines.md", kept];
|
|
1278
|
+
default:
|
|
1279
|
+
return pkg === "markdown-it" || pkg.startsWith("markdown-it-") ? ["engines.md", "markdown", kept] : [kept];
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1133
1282
|
function replacement(pkg) {
|
|
1134
1283
|
switch (pkg) {
|
|
1135
1284
|
case "@11ty/eleventy-img":
|
|
@@ -1345,6 +1494,7 @@ function draftConfig(name, text, extensions, ports = [], eleventyMajor2, helpers
|
|
|
1345
1494
|
const declared = declaredNames(text);
|
|
1346
1495
|
const byHand = [];
|
|
1347
1496
|
const passthrough = [], watch = [], todo = [];
|
|
1497
|
+
const defines = (...names) => ({ defines: names });
|
|
1348
1498
|
const aliases = [];
|
|
1349
1499
|
const ported = [];
|
|
1350
1500
|
for (const c of code.matchAll(CALL)) {
|
|
@@ -1388,12 +1538,12 @@ function draftConfig(name, text, extensions, ports = [], eleventyMajor2, helpers
|
|
|
1388
1538
|
case "addLiquidFilter":
|
|
1389
1539
|
if (!port()) {
|
|
1390
1540
|
todo.push(`filters: ${arg}`);
|
|
1391
|
-
byHand.push([at, `${method}("${arg}") -> \`filters: { ${arg}: ... }\` (async functions are awaited)`]);
|
|
1541
|
+
byHand.push([at, `${method}("${arg}") -> \`filters: { ${arg}: ... }\` (async functions are awaited)`, defines(`filters.${arg}`)]);
|
|
1392
1542
|
}
|
|
1393
1543
|
break;
|
|
1394
1544
|
case "addNunjucksAsyncFilter":
|
|
1395
1545
|
todo.push(`filters: ${arg}`);
|
|
1396
|
-
byHand.push([at, `${method}("${arg}") -> \`filters: { ${arg}: async (value) => ... }\`: return the result instead of calling the callback`]);
|
|
1546
|
+
byHand.push([at, `${method}("${arg}") -> \`filters: { ${arg}: async (value) => ... }\`: return the result instead of calling the callback`, defines(`filters.${arg}`)]);
|
|
1397
1547
|
break;
|
|
1398
1548
|
case "addShortcode":
|
|
1399
1549
|
case "addAsyncShortcode":
|
|
@@ -1402,7 +1552,7 @@ function draftConfig(name, text, extensions, ports = [], eleventyMajor2, helpers
|
|
|
1402
1552
|
case "addLiquidShortcode":
|
|
1403
1553
|
if (!port()) {
|
|
1404
1554
|
todo.push(`filters: ${arg}`);
|
|
1405
|
-
byHand.push([at, `${method}("${arg}") -> a filter: \`filters: { ${arg}: ... }\`. Nunjucks keeps \`{% ${arg} ... %}\`; in Liquid it's \`{{ x | ${arg} }}
|
|
1555
|
+
byHand.push([at, `${method}("${arg}") -> a filter: \`filters: { ${arg}: ... }\`. Nunjucks keeps \`{% ${arg} ... %}\`; in Liquid it's \`{{ x | ${arg} }}\``, defines(`filters.${arg}`)]);
|
|
1406
1556
|
}
|
|
1407
1557
|
break;
|
|
1408
1558
|
case "addPairedShortcode":
|
|
@@ -1412,42 +1562,42 @@ function draftConfig(name, text, extensions, ports = [], eleventyMajor2, helpers
|
|
|
1412
1562
|
case "addPairedLiquidShortcode":
|
|
1413
1563
|
if (!port()) {
|
|
1414
1564
|
todo.push(`filters: ${arg}`);
|
|
1415
|
-
byHand.push([at, `${method}("${arg}") -> a filter that gets the content first. Nunjucks keeps \`{% ${arg} %}...{% end${arg} %}\`; in Markdown, a \`::: ${arg}\` container`]);
|
|
1565
|
+
byHand.push([at, `${method}("${arg}") -> a filter that gets the content first. Nunjucks keeps \`{% ${arg} %}...{% end${arg} %}\`; in Markdown, a \`::: ${arg}\` container`, defines(`filters.${arg}`)]);
|
|
1416
1566
|
}
|
|
1417
1567
|
break;
|
|
1418
1568
|
case "addCollection":
|
|
1419
1569
|
todo.push(`collections: ${arg}`);
|
|
1420
|
-
byHand.push([at, `addCollection("${arg}") -> \`collections: { ${arg}: (pages) => ... }\`: getAll() is pages.all(), getFilteredByTag is pages.byTag, getFilteredByGlob is pages.byGlob`]);
|
|
1570
|
+
byHand.push([at, `addCollection("${arg}") -> \`collections: { ${arg}: (pages) => ... }\`: getAll() is pages.all(), getFilteredByTag is pages.byTag, getFilteredByGlob is pages.byGlob`, defines(`collections.${arg}`)]);
|
|
1421
1571
|
break;
|
|
1422
1572
|
case "addTransform":
|
|
1423
|
-
byHand.push([at, `addTransform("${arg}") -> \`transforms: { ${arg}: (content, page) => content }\` (an HTML minifier is \`minifyPlugin()\`)`]);
|
|
1573
|
+
byHand.push([at, `addTransform("${arg}") -> \`transforms: { ${arg}: (content, page) => content }\` (an HTML minifier is \`minifyPlugin()\`)`, defines(`transforms.${arg}`, .../min/i.test(arg) ? ["plugin:ssqch/minify"] : [])]);
|
|
1424
1574
|
break;
|
|
1425
1575
|
case "addGlobalData":
|
|
1426
|
-
byHand.push([at, `addGlobalData("${arg}") -> \`data: { ${arg}: value or function }
|
|
1576
|
+
byHand.push([at, `addGlobalData("${arg}") -> \`data: { ${arg}: value or function }\``, defines(`data.${arg}`)]);
|
|
1427
1577
|
break;
|
|
1428
1578
|
case "addNunjucksTag":
|
|
1429
1579
|
case "addLiquidTag":
|
|
1430
1580
|
todo.push(`filters: ${arg}`);
|
|
1431
|
-
byHand.push([at, `${method}("${arg}") -> a custom tag is a filter in ssqch: \`filters: { ${arg}: ... }\`, and \`{% ${arg} ... %}\` keeps working in Nunjucks`]);
|
|
1581
|
+
byHand.push([at, `${method}("${arg}") -> a custom tag is a filter in ssqch: \`filters: { ${arg}: ... }\`, and \`{% ${arg} ... %}\` keeps working in Nunjucks`, defines(`filters.${arg}`)]);
|
|
1432
1582
|
break;
|
|
1433
1583
|
case "addNunjucksGlobal":
|
|
1434
|
-
byHand.push([at, `addNunjucksGlobal("${arg}") -> \`data: { ${arg}: value }\`, or a filter for a function`]);
|
|
1584
|
+
byHand.push([at, `addNunjucksGlobal("${arg}") -> \`data: { ${arg}: value }\`, or a filter for a function`, defines(`data.${arg}`, `filters.${arg}`)]);
|
|
1435
1585
|
break;
|
|
1436
1586
|
case "addMarkdownHighlighter":
|
|
1437
|
-
byHand.push([at, "addMarkdownHighlighter -> `markdown: { highlight: true }`, or a fence hook for a highlighter of your own"]);
|
|
1587
|
+
byHand.push([at, "addMarkdownHighlighter -> `markdown: { highlight: true }`, or a fence hook for a highlighter of your own", defines("markdown.highlight", "engines.md")]);
|
|
1438
1588
|
break;
|
|
1439
1589
|
case "addPlugin": {
|
|
1440
1590
|
const pkg = pluginPackage(code, arg);
|
|
1441
1591
|
const known = pkg !== void 0 && `require("${pkg}")`.search(REQUIRE) !== -1 && replacement(pkg) !== void 0;
|
|
1442
1592
|
const from = pkg === void 0 ? "" : ` (from ${pkg})`;
|
|
1443
|
-
if (known) byHand.push([at, `addPlugin(${arg})${from} -> see its package below
|
|
1593
|
+
if (known) byHand.push([at, `addPlugin(${arg})${from} -> see its package below`, defines(...packageDefines(pkg))]);
|
|
1444
1594
|
else if (pkg !== void 0 && followed.has(pkg)) byHand.push([at, `addPlugin(${arg})${from}: the site's own plugin. What it adds is listed with its own file and line, and what could be copied as written is in the draft`]);
|
|
1445
1595
|
else byHand.push([at, `addPlugin(${arg})${from}: a plugin ssqch doesn't know, so the filters, shortcodes and transforms it adds aren't listed here. Read its source and port them, or put it in \`plugins: [...]\` if it's written for ssqch`]);
|
|
1446
1596
|
break;
|
|
1447
1597
|
}
|
|
1448
1598
|
case "setLibrary": {
|
|
1449
1599
|
const library = quoted === "md" && args[1] !== void 0 ? trim(args[1]) : void 0;
|
|
1450
|
-
if (library !== void 0) byHand.push([at, `setLibrary("md", ${library.length > 60 || library.includes("\n") ? "..." : library}) -> keep your markdown-it as it is with \`engines: { ${library === "md" ? "md" : `md: ${/^[A-Za-z_$][\w$]*$/.test(library) ? library : "yourMarkdownIt"}`} }\` (bring its import and setup into the config; \`ssqch docs "moving with identical output first"\`), or ssqch's own Markdown: \`markdown: { ... }\` options, render hooks and containers
|
|
1600
|
+
if (library !== void 0) byHand.push([at, `setLibrary("md", ${library.length > 60 || library.includes("\n") ? "..." : library}) -> keep your markdown-it as it is with \`engines: { ${library === "md" ? "md" : `md: ${/^[A-Za-z_$][\w$]*$/.test(library) ? library : "yourMarkdownIt"}`} }\` (bring its import and setup into the config; \`ssqch docs "moving with identical output first"\`), or ssqch's own Markdown: \`markdown: { ... }\` options, render hooks and containers`, defines("engines.md", "markdown")]);
|
|
1451
1601
|
else if (quoted !== void 0 && quoted !== "md") byHand.push([at, `setLibrary("${quoted}") -> ssqch has its own; a library of your own is an engine: \`engines: { ${quoted}: { render: (source, data) => ... } }\``]);
|
|
1452
1602
|
else byHand.push([at, "setLibrary -> ssqch renders Markdown itself: `markdown: { ... }` options, render hooks and containers"]);
|
|
1453
1603
|
break;
|
|
@@ -1482,7 +1632,7 @@ function draftConfig(name, text, extensions, ports = [], eleventyMajor2, helpers
|
|
|
1482
1632
|
else if (!/\bslugify\s*:/.test(code)) markdownDefaults.push(["markdown-it-anchor's ids (encodeURIComponent of the text); take this out for ssqch's.", 'headingIds: "markdown-it-anchor"']);
|
|
1483
1633
|
if (eleventyMajor2 !== void 0 && (eleventyMajor2 >= 3 || eleventyMajor2 === 2 && !ownLibrary)) markdownDefaults.push([`Eleventy ${eleventyMajor2} turns off markdown-it's indented code blocks (\`md.disable("code")\`).`, "indentedCode: false"]);
|
|
1484
1634
|
}
|
|
1485
|
-
for (const pkg of packages) byHand.push([name, `${pkg} -> ${replacement(pkg)}
|
|
1635
|
+
for (const pkg of packages) byHand.push([name, `${pkg} -> ${replacement(pkg)}`, defines(...packageDefines(pkg))]);
|
|
1486
1636
|
const engine = (key) => {
|
|
1487
1637
|
const value = setting(code, key);
|
|
1488
1638
|
if (value === "njk") return '"njk"';
|
|
@@ -1887,8 +2037,23 @@ var JEKYLL_PAGE = {
|
|
|
1887
2037
|
previous: "`navPager(collections.posts, page.url).previous`"
|
|
1888
2038
|
};
|
|
1889
2039
|
var LIQUID_TAGS = /* @__PURE__ */ new Set(["assign", "capture", "endcapture", "case", "when", "endcase", "comment", "endcomment", "cycle", "decrement", "increment", "echo", "for", "endfor", "break", "continue", "if", "elsif", "else", "endif", "unless", "endunless", "include", "include_relative", "render", "layout", "liquid", "raw", "endraw", "tablerow", "endtablerow", "highlight", "endhighlight", "link", "post_url", "block", "endblock"]);
|
|
2040
|
+
function withoutBlankAfterFrontMatter(text) {
|
|
2041
|
+
const open = /^---[ \t]*\r?\n/.exec(text);
|
|
2042
|
+
if (!open) return void 0;
|
|
2043
|
+
const close = /^---[ \t]*(?:\r?\n|$)/m.exec(text.slice(open[0].length));
|
|
2044
|
+
if (!close) return void 0;
|
|
2045
|
+
const end = open[0].length + close.index + close[0].length;
|
|
2046
|
+
const blank = /^(?:[ \t]*\r?\n)+/.exec(text.slice(end));
|
|
2047
|
+
return blank ? text.slice(0, end) + text.slice(end + blank[0].length) : void 0;
|
|
2048
|
+
}
|
|
2049
|
+
function writesHtml(rel, text) {
|
|
2050
|
+
const front = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text)?.[1] ?? "";
|
|
2051
|
+
const permalink = /^permalink:\s*["']?([^"'\s#]+)/m.exec(front)?.[1];
|
|
2052
|
+
if (permalink && /\.[A-Za-z0-9]+$/.test(permalink)) return /\.html?$/i.test(permalink);
|
|
2053
|
+
return /\.(?:md|markdown|html?)$/i.test(rel);
|
|
2054
|
+
}
|
|
1890
2055
|
var JEKYLL_PLUGINS = {
|
|
1891
|
-
"jekyll-sitemap": { use: ['import { sitemapPlugin } from "ssqch/sitemap";', "sitemapPlugin({ url: site.url })"], say: "`sitemapPlugin({ url: site.url })`, in the draft (
|
|
2056
|
+
"jekyll-sitemap": { use: ['import { sitemapPlugin } from "ssqch/sitemap";', "sitemapPlugin({ url: site.url })"], say: "`sitemapPlugin({ url: site.url })`, in the draft (it needs the site's address: with no `url` in the config, the draft leaves it commented out until there is one). jekyll-sitemap also wrote `/robots.txt` when the site had none: `robots.liquid`, in the plan. Its own sitemap's format (the order, `xsi:schemaLocation`) is a template of your own if the bytes matter" },
|
|
1892
2057
|
"jekyll-redirect-from": { use: ['import { redirectsPlugin } from "ssqch/redirects";', "redirectsPlugin()"], say: "`redirectsPlugin()`, in the draft: `redirect_from` works as it is (templates read it as `aliases`); `_includes/hooks/redirect.*` is its page's markup. jekyll-redirect-from also wrote `/redirects.json`: `redirects.liquid`, in the plan" },
|
|
1893
2058
|
"jekyll-feed": { use: ['import { rssPlugin } from "ssqch/rss";', "rssPlugin()"], say: "`rssPlugin()` is in the draft; the feed itself is a template of the site's (`feed.xml.liquid` with `permalink: /feed.xml`): `ssqch docs rssPlugin`" },
|
|
1894
2059
|
"jekyll-seo-tag": { say: '`{% seo %}` becomes an include: `ssqch docs "From jekyll-seo-tag"` has one that writes its tags' },
|
|
@@ -2039,6 +2204,11 @@ function jekyll(dir) {
|
|
|
2039
2204
|
next = next.replace(/\{%(-?)\s*seo\b[^%]*?(-?)%\}/g, "{%$1 include seo.liquid $2%}");
|
|
2040
2205
|
changes = [...changes, "{% seo %} -> {% include seo.liquid %}"];
|
|
2041
2206
|
}
|
|
2207
|
+
const trimmed = withoutBlankAfterFrontMatter(next);
|
|
2208
|
+
if (trimmed !== void 0 && !templateDir && !writesHtml(entry.rel, next)) {
|
|
2209
|
+
next = trimmed;
|
|
2210
|
+
changes = [...changes, "the blank line after the front matter out (Jekyll dropped it; here it would be the file's first line)"];
|
|
2211
|
+
}
|
|
2042
2212
|
if (changes.length) plan.edits.push([entry.rel, changes, next]);
|
|
2043
2213
|
for (const what of left2) plan.byHand.push([entry.rel, what]);
|
|
2044
2214
|
for (const m of text.matchAll(/\{%-?\s*([a-z_][\w-]*)/g)) {
|
|
@@ -2207,8 +2377,8 @@ ${body}`;
|
|
|
2207
2377
|
const gemfile = readUtf8(path.join(dir, "Gemfile")) ?? "";
|
|
2208
2378
|
const named = /* @__PURE__ */ new Set([...list("plugins"), ...list("gems"), ...[...gemfile.matchAll(/^\s*gem\s+["']([^"']+)["']/gm)].map((m) => m[1])]);
|
|
2209
2379
|
if (named.has("github-pages")) for (const p of GITHUB_PAGES_PLUGINS) named.add(p);
|
|
2210
|
-
const imports = ['import { defineConfig, readData } from "ssqch";'];
|
|
2211
|
-
const plugins = [];
|
|
2380
|
+
const imports = ['import { defineConfig, readData } from "ssqch";', 'import { fromJekyll } from "ssqch/from-jekyll";'];
|
|
2381
|
+
const plugins = ["fromJekyll()"];
|
|
2212
2382
|
for (const name of [...named].sort(compareText)) {
|
|
2213
2383
|
const known = JEKYLL_PLUGINS[name];
|
|
2214
2384
|
if (!known) {
|
|
@@ -2272,9 +2442,9 @@ ${body}`;
|
|
|
2272
2442
|
const loadPaths = isPlainObject(config.sass) && Array.isArray(config.sass.load_paths) ? config.sass.load_paths.map(String) : isDir(path.join(dir, "_sass")) ? ["_sass"] : [];
|
|
2273
2443
|
plugins.push(`sassPlugin({ files: { ${files.join(", ")} }${loadPaths.length ? `, loadPaths: ${JSON.stringify(loadPaths)}` : ""}, charset: false })`);
|
|
2274
2444
|
}
|
|
2275
|
-
const markdown = [
|
|
2445
|
+
const markdown = [];
|
|
2276
2446
|
const kramdown = isPlainObject(config.kramdown) ? config.kramdown : {};
|
|
2277
|
-
if (kramdown.auto_ids === false) markdown
|
|
2447
|
+
if (kramdown.auto_ids === false) markdown.push("headingIds: false");
|
|
2278
2448
|
if (kramdown.smart_quotes !== void 0 || kramdown.input === "GFM" && kramdown.hard_wrap === true) plan.byHand.push([configFile, "kramdown's `smart_quotes` or `hard_wrap`: check the draft's `markdown` against them (`breaks: true` for `hard_wrap`)"]);
|
|
2279
2449
|
if (typeof config.markdown === "string" && !/kramdown/i.test(config.markdown)) plan.byHand.push([configFile, `markdown: ${config.markdown}: the draft's options are kramdown's; ssqch's Markdown is CommonMark with extensions (\`ssqch docs markdown\`)`]);
|
|
2280
2450
|
let out = `// A first draft, written by \`ssqch scout\` from ${configFile}.
|
|
@@ -2294,6 +2464,11 @@ const site = readData(${JSON.stringify(configFile)});
|
|
|
2294
2464
|
|
|
2295
2465
|
export default defineConfig({
|
|
2296
2466
|
`;
|
|
2467
|
+
const SITEMAP = "sitemapPlugin({ url: site.url })";
|
|
2468
|
+
if (plugins.includes(SITEMAP) && (typeof config.url !== "string" || config.url === "") && !urlFromCname) {
|
|
2469
|
+
plugins[plugins.indexOf(SITEMAP)] = `/* ${SITEMAP}: needs \`url\` in ${configFile} */`;
|
|
2470
|
+
plan.byHand.push([configFile, "no `url`: `sitemapPlugin()` needs the site's address (`url: https://example.com`), so it's commented out in the draft until there is one"]);
|
|
2471
|
+
}
|
|
2297
2472
|
const builtIn = /* @__PURE__ */ new Set(["txt"]);
|
|
2298
2473
|
out += ` // Markdown and HTML pages run through Liquid first, as in Jekyll.
|
|
2299
2474
|
templateFormats: ${JSON.stringify(["liquid", "md", "html", ...otherFormats]).replaceAll(",", ", ")},
|
|
@@ -2310,9 +2485,7 @@ export default defineConfig({
|
|
|
2310
2485
|
if (output !== "_site") dirs.push(`output: ${JSON.stringify(output)}`);
|
|
2311
2486
|
out += ` dirs: { ${dirs.join(", ")} },
|
|
2312
2487
|
`;
|
|
2313
|
-
out +=
|
|
2314
|
-
out += " // Templates see Jekyll's `page` (front matter too: `page.title`) and `site` (`site.posts`,\n // each collection, `site.data`, `site.categories`), so the layouts and includes run as written.\n jekyllTemplates: true,\n";
|
|
2315
|
-
out += ` // kramdown's habits: markdown="1", its heading ids, smart quotes, no bare-URL links, URLs as written.
|
|
2488
|
+
if (markdown.length) out += ` // kramdown's auto_ids is off in ${configFile}.
|
|
2316
2489
|
markdown: { ${markdown.join(", ")} },
|
|
2317
2490
|
`;
|
|
2318
2491
|
out += ` // ${configFile}'s \`exclude\`, and what Jekyll leaves out by itself.
|
|
@@ -2546,7 +2719,7 @@ function hugo(dir) {
|
|
|
2546
2719
|
const calls = blockCalls.sorted();
|
|
2547
2720
|
if (calls.length || inlineCalls.seen.size) {
|
|
2548
2721
|
const pages = new Set([...calls, ...inlineCalls.sorted()].flatMap(([, { files }]) => [...files])).size;
|
|
2549
|
-
plan.byHand.push([contentDir, `${(/* @__PURE__ */ new Set([...blockCalls.seen.keys(), ...inlineCalls.seen.keys()])).size} shortcodes, called in ${pages} ${pages === 1 ? "page" : "pages"}: \`
|
|
2722
|
+
plan.byHand.push([contentDir, `${(/* @__PURE__ */ new Set([...blockCalls.seen.keys(), ...inlineCalls.seen.keys()])).size} shortcodes, called in ${pages} ${pages === 1 ? "page" : "pages"}: \`fromHugo()\` (in the draft) reads each call as a container, rendered by \`_includes/containers/<name>.*\` (one inside a line of text too, in its place); the draft has a template to port for each of the site's own`, { code: "hugo-shortcodes", status: "option", files: pages, option: 'markdown: { shortcodes: "hugo" }', defines: ["plugin:fromHugo"], docs: "shortcodes" }]);
|
|
2550
2723
|
}
|
|
2551
2724
|
for (const [name, { count, files, first }] of calls) {
|
|
2552
2725
|
const own = shortcodeFiles.get(name);
|
|
@@ -2559,7 +2732,19 @@ function hugo(dir) {
|
|
|
2559
2732
|
<div class="${name}">{{ container.content | safe }}</div>
|
|
2560
2733
|
`]);
|
|
2561
2734
|
}
|
|
2562
|
-
for (const [name, { count, files, first }] of inlineCalls.sorted())
|
|
2735
|
+
for (const [name, { count, files, first }] of inlineCalls.sorted()) {
|
|
2736
|
+
const own = shortcodeFiles.get(name);
|
|
2737
|
+
const whose = own ? `the site's own (${own})` : HUGO_BUILT_IN_SHORTCODES.has(name) ? "Hugo's" : "nobody's (no template for it)";
|
|
2738
|
+
const draft = own && /^[\w-]+$/.test(name) ? `_includes/containers/${name}.jinja` : void 0;
|
|
2739
|
+
const drafted = draft !== void 0 && plan.newFiles.some(([file]) => file === draft);
|
|
2740
|
+
plan.byHand.push([first, `\`{{< ${name} >}}\` inside a line of text, ${whose} (${uses(count, files.size)}): its container template renders it in place, with \`container.inline\` true${draft ? `; port its template into ${draft} (in the draft)` : `; write \`_includes/containers/${name}.jinja\``}`, { code: "hugo-inline-shortcode", status: own ? "site" : "ssqch", count, files: files.size, docs: "shortcodes" }]);
|
|
2741
|
+
if (draft && !drafted) plan.newFiles.push([draft, `a container for the ${name} shortcode, to port from ${own}`, `{#- The ${name} shortcode (${own}), as a container: port its Go template here.
|
|
2742
|
+
It's called inside a line of text, so container.inline is true and what it writes goes in
|
|
2743
|
+
the line. container.args is what the call wrote after the name, container.props its
|
|
2744
|
+
named parameters (key="value"), and container.content what's between its tags, rendered. -#}
|
|
2745
|
+
<span class="${name}">{{ container.content | safe }}</span>
|
|
2746
|
+
`]);
|
|
2747
|
+
}
|
|
2563
2748
|
if (templated) plan.byHand.push([templated, `\`{{ }}\` or \`{% %}\` as text in ${templatedCount} ${templatedCount === 1 ? "page" : "pages"} (this is the first): Hugo prints them as they are, and so does ssqch with \`markdownEngine: false\` (in the draft)`, { code: "hugo-template-text", status: "option", files: templatedCount, option: "markdownEngine: false" }]);
|
|
2564
2749
|
if (sections) plan.byHand.push([contentDir, `${sections} ${sections === 1 ? "section" : "sections"} (\`_index.md\`): ssqch's sections are folders with directory data (\`<folder>/<folder>.json\` for layout and permalink) and a collection (\`tags\`), and the section page a page of its own`, { code: "hugo-sections", status: "ssqch", count: sections, files: sections, docs: "directory data" }]);
|
|
2565
2750
|
if (cascades) plan.byHand.push([contentDir, `\`cascade\` in ${cascades} ${cascades === 1 ? "page's" : "pages'"} front matter: ssqch's is directory data, which every page below it gets`, { code: "hugo-cascade", status: "ssqch", files: cascades, docs: "directory data" }]);
|
|
@@ -2592,7 +2777,7 @@ function hugo(dir) {
|
|
|
2592
2777
|
if (baseURL) site.url = baseURL;
|
|
2593
2778
|
if (isPlainObject(hugoKey(config, "params"))) site.params = hugoKey(config, "params");
|
|
2594
2779
|
const dirs = [`input: ${JSON.stringify(contentDir)}`, `output: ${JSON.stringify(output)}`, 'includes: "../_includes"', ...hasDir("data") ? ['data: "../data"'] : []];
|
|
2595
|
-
const imports = ['import { defineConfig } from "ssqch";', 'import { linksPlugin } from "ssqch/links";', ...baseURL ? ['import { sitemapPlugin } from "ssqch/sitemap";'] : []];
|
|
2780
|
+
const imports = ['import { defineConfig } from "ssqch";', 'import { fromHugo } from "ssqch/from-hugo";', 'import { linksPlugin } from "ssqch/links";', ...baseURL ? ['import { sitemapPlugin } from "ssqch/sitemap";'] : []];
|
|
2596
2781
|
let out = `// A first draft, written by \`ssqch scout\` from ${configFile ?? "the Hugo site"}.
|
|
2597
2782
|
// \`ssqch docs --from hugo\` has the whole mapping.
|
|
2598
2783
|
${imports.join("\n")}
|
|
@@ -2605,11 +2790,12 @@ export default defineConfig({
|
|
|
2605
2790
|
base: ${JSON.stringify(basePath(baseURL))},
|
|
2606
2791
|
`;
|
|
2607
2792
|
out += " // Hugo doesn't run template code in content, and its shortcodes on a line of their own are\n // containers (_includes/containers/<name>.jinja).\n markdownEngine: false,\n";
|
|
2608
|
-
out += ' markdown: {
|
|
2793
|
+
out += ' markdown: { highlight: { classes: "pygments" } },\n';
|
|
2609
2794
|
if (hasDir("static")) out += ' passthrough: [{ static: "." }],\n';
|
|
2610
2795
|
out += ` data: { site: ${JSON.stringify(sortedKeys(site))} },
|
|
2611
2796
|
`;
|
|
2612
2797
|
out += ` plugins: [${[
|
|
2798
|
+
"fromHugo()",
|
|
2613
2799
|
...baseURL ? [`sitemapPlugin({ url: ${JSON.stringify(baseURL)} })`] : [],
|
|
2614
2800
|
// Hugo doesn't check links, so one that was broken there warns rather than failing the move's build.
|
|
2615
2801
|
"linksPlugin({ fail: false })"
|
|
@@ -2642,9 +2828,9 @@ var MKDOCS_PLUGINS = {
|
|
|
2642
2828
|
i18n: { say: "`ssqch docs multilingual`", status: "ssqch" }
|
|
2643
2829
|
};
|
|
2644
2830
|
var MKDOCS_EXTENSIONS = {
|
|
2645
|
-
admonition: { say:
|
|
2646
|
-
"pymdownx.details": { say:
|
|
2647
|
-
"pymdownx.tabbed": { say:
|
|
2831
|
+
admonition: { say: "`!!!` admonitions: `fromMkdocs()` (in the draft) writes them as Python-Markdown does", status: "option", option: 'markdown: { admonitions: "mkdocs" }' },
|
|
2832
|
+
"pymdownx.details": { say: "`???` collapsible admonitions: `fromMkdocs()` (in the draft)", status: "option", option: 'markdown: { admonitions: "mkdocs" }' },
|
|
2833
|
+
"pymdownx.tabbed": { say: "`===` tabs: `fromMkdocs()` (in the draft) writes them in the alternate style", status: "option", option: 'markdown: { tabs: "mkdocs" }' },
|
|
2648
2834
|
"pymdownx.superfences": { say: "fences, built in; custom fences (mermaid) are a fence hook (`_includes/hooks/fence-mermaid.<ext>`)", status: "ssqch" },
|
|
2649
2835
|
"pymdownx.highlight": { say: "`markdown: { highlight: { classes: \"pygments\" } }` (in the draft): Pygments' class names, cut by ssqch's grammars (the tokens can differ from Pygments', and the wrapper is a fence hook's: `_includes/hooks/fence.*`)", status: "option", option: 'markdown: { highlight: { classes: "pygments" } }' },
|
|
2650
2836
|
codehilite: { say: "`markdown: { highlight: { classes: \"pygments\" } }` (in the draft) gives tokens Pygments' class names, cut by ssqch's grammars; codehilite's markup isn't the same (`<div class=\"codehilite\"><pre><span></span><code>`), and its tokens are Pygments', so a byte-for-byte move needs Pygments itself, or a fence hook (`_includes/hooks/fence.*`) for the wrapper", status: "option", option: 'markdown: { highlight: { classes: "pygments" } }' },
|
|
@@ -2666,7 +2852,7 @@ var MKDOCS_EXTENSIONS = {
|
|
|
2666
2852
|
attr_list: { say: "attributes (`{#id .class}`), built in; on headings, ssqch keeps ids and classes", status: "ssqch" },
|
|
2667
2853
|
md_in_html: { say: 'Markdown inside HTML with the bare `markdown` attribute: not in ssqch yet as written; `markdown: { htmlMarkdown: "kramdown" }` reads `markdown="1"`', status: "not-yet" },
|
|
2668
2854
|
footnotes: { say: "footnotes, built in (their markup is a `footnotes` hook's)", status: "ssqch" },
|
|
2669
|
-
toc: { say: "`
|
|
2855
|
+
toc: { say: "`fromMkdocs()` (in the draft): toc's default ids (a repeated heading's `_1` too; a `slugify` of the site's own needs a function). The table of contents is `page.headings` and the `toc` filter", status: "option", option: 'markdown: { headingIds: "python-markdown" }' },
|
|
2670
2856
|
def_list: { say: "`markdown: { definitionLists: true }` (in the draft)", status: "option", option: "markdown: { definitionLists: true }" },
|
|
2671
2857
|
abbr: { say: "abbreviations: not in ssqch yet", status: "not-yet" },
|
|
2672
2858
|
tables: { say: "tables, built in", status: "ssqch" },
|
|
@@ -2695,7 +2881,7 @@ function mkdocs(dir) {
|
|
|
2695
2881
|
const extensions = named(config.markdown_extensions);
|
|
2696
2882
|
const plugins = config.plugins === void 0 ? ["search"] : named(config.plugins);
|
|
2697
2883
|
const theme = isPlainObject(config.theme) ? config.theme.name : config.theme;
|
|
2698
|
-
if (typeof theme === "string") plan.byHand.push([`${configFile}: theme`, `the ${theme === "material" ? "Material" : theme} theme's templates are Jinja, which ssqch runs as written with \`
|
|
2884
|
+
if (typeof theme === "string") plan.byHand.push([`${configFile}: theme`, `the ${theme === "material" ? "Material" : theme} theme's templates are Jinja, which ssqch runs as written with \`fromMkdocs({ templates: true })\` (in the draft, to turn on once they're there): it gives them MkDocs' context (\`config\`, \`nav\`, \`page\`, \`base_url\`, the \`url\` filter). Copy the theme's templates from its Python package into an ssqch theme first (\`ssqch docs --from mkdocs\`, "The theme")`, { code: "mkdocs-theme", status: "option", option: "mkdocsTemplates: true", docs: "mkdocsTemplates" }]);
|
|
2699
2885
|
for (const name of plugins) {
|
|
2700
2886
|
const known = MKDOCS_PLUGINS[name.replace(/^material\//, "")];
|
|
2701
2887
|
plan.byHand.push([`${configFile}: plugins`, `\`${name}\`: ${known?.say ?? "not in ssqch yet: port it as a plugin (`ssqch docs plugins`)"}`, { code: "mkdocs-plugin", status: known?.status ?? "site" }]);
|
|
@@ -2713,9 +2899,9 @@ function mkdocs(dir) {
|
|
|
2713
2899
|
plan.byHand.push([`${configFile}: site_url`, "MkDocs writes `sitemap.xml.gz` beside `sitemap.xml`: `sitemapPlugin()` writes the `.xml`; the gzipped copy isn't in ssqch yet (an `afterBuild` step with `node:zlib`)", { code: "mkdocs-sitemap-gz", status: "not-yet" }]);
|
|
2714
2900
|
if (isFile(path.join(dir, "hooks.py")) || config.hooks) plan.byHand.push([`${configFile}: hooks`, "Python hooks don't run in ssqch: port each as a plugin or a filter (`ssqch docs plugins`)", { code: "mkdocs-hooks", status: "site", docs: "plugins" }]);
|
|
2715
2901
|
const syntax = [
|
|
2716
|
-
["links to .md files", /\]\((?![a-z]+:)[^)\s#]*\.md(?:#[^)\s]*)?\)|^[ \t]*\[[^\]\n]+\]:[ \t]*(?![a-z]+:)[^\s#]*\.md(?:#\S*)?[ \t]*$/gm,
|
|
2717
|
-
["admonitions (`!!!`, `???`)", /^[ \t]*(?:!!!|\?\?\?\+?)[ \t]+\w/gm,
|
|
2718
|
-
["tabs (`===`)", /^[ \t]*===[+!]{0,2}[ \t]+"/gm,
|
|
2902
|
+
["links to .md files", /\]\((?![a-z]+:)[^)\s#]*\.md(?:#[^)\s]*)?\)|^[ \t]*\[[^\]\n]+\]:[ \t]*(?![a-z]+:)[^\s#]*\.md(?:#\S*)?[ \t]*$/gm, "`fromMkdocs()` (in the draft) links each to its page's URL, as MkDocs does", "mkdocs-md-links", "option"],
|
|
2903
|
+
["admonitions (`!!!`, `???`)", /^[ \t]*(?:!!!|\?\?\?\+?)[ \t]+\w/gm, "`fromMkdocs()` (in the draft)", "mkdocs-admonitions", "option"],
|
|
2904
|
+
["tabs (`===`)", /^[ \t]*===[+!]{0,2}[ \t]+"/gm, "`fromMkdocs()` (in the draft)", "mkdocs-tabs", "option"],
|
|
2719
2905
|
["snippets (`--8<--`)", /^[ \t]*-+8<-+/gm, "not in ssqch yet as written", "mkdocs-snippets", "not-yet"],
|
|
2720
2906
|
["icons and emoji (`:name:`)", /:(?:material|fontawesome|octicons|simple)-[\w-]+:/g, "not in ssqch yet", "mkdocs-icons", "not-yet"],
|
|
2721
2907
|
["bare `markdown` attributes", /<[a-z][^>]*\smarkdown(?=[\s>])/g, 'not in ssqch yet as written: `htmlMarkdown: "kramdown"` reads `markdown="1"`', "mkdocs-md-in-html", "not-yet"],
|
|
@@ -2741,7 +2927,7 @@ function mkdocs(dir) {
|
|
|
2741
2927
|
const site = {};
|
|
2742
2928
|
for (const [from, to] of [["site_name", "name"], ["site_url", "url"], ["site_description", "description"], ["site_author", "author"], ["repo_url", "repo_url"], ["edit_uri", "edit_uri"], ["copyright", "copyright"]]) if (typeof config[from] === "string") site[to] = config[from];
|
|
2743
2929
|
if (isPlainObject(config.extra)) site.extra = config.extra;
|
|
2744
|
-
const markdown = [
|
|
2930
|
+
const markdown = [];
|
|
2745
2931
|
if (extensions.some((e) => e === "pymdownx.highlight" || e === "codehilite")) markdown.push('highlight: { classes: "pygments" }');
|
|
2746
2932
|
if (extensions.includes("def_list")) markdown.push("definitionLists: true");
|
|
2747
2933
|
if (extensions.includes("smarty")) markdown.push("smartPunctuation: true");
|
|
@@ -2756,7 +2942,7 @@ function mkdocs(dir) {
|
|
|
2756
2942
|
return out2;
|
|
2757
2943
|
})();
|
|
2758
2944
|
const url = typeof config.site_url === "string" ? config.site_url.replace(/\/$/, "") : void 0;
|
|
2759
|
-
const imports = ['import { defineConfig } from "ssqch";', 'import { linksPlugin } from "ssqch/links";', ...url ? ['import { sitemapPlugin } from "ssqch/sitemap";'] : [], ...redirects ? ['import { redirectsPlugin } from "ssqch/redirects";'] : []];
|
|
2945
|
+
const imports = ['import { defineConfig } from "ssqch";', 'import { fromMkdocs } from "ssqch/from-mkdocs";', 'import { linksPlugin } from "ssqch/links";', ...url ? ['import { sitemapPlugin } from "ssqch/sitemap";'] : [], ...redirects ? ['import { redirectsPlugin } from "ssqch/redirects";'] : []];
|
|
2760
2946
|
let out = `// A first draft, written by \`ssqch scout\` from ${configFile}.
|
|
2761
2947
|
// \`ssqch docs --from mkdocs\` has the whole mapping. The sidebar is _data/nav.yml (navTree).
|
|
2762
2948
|
${imports.join("\n")}
|
|
@@ -2775,7 +2961,7 @@ export default defineConfig({
|
|
|
2775
2961
|
// "The theme"), then turn these on.
|
|
2776
2962
|
// theme: "theme", mkdocsTemplates: true,
|
|
2777
2963
|
`;
|
|
2778
|
-
out += ` markdown: { ${markdown.join(", ")} },
|
|
2964
|
+
if (markdown.length) out += ` markdown: { ${markdown.join(", ")} },
|
|
2779
2965
|
`;
|
|
2780
2966
|
const copied = walk(path.join(dir, docsDir), (name) => name.startsWith(".") || name === "node_modules", false).filter((e) => e.isFile && !/\.md$/i.test(e.name) && !(customDir && path.join(dir, docsDir, e.rel).startsWith(path.join(dir, customDir) + path.sep)));
|
|
2781
2967
|
const others = [...new Set(copied.filter((e) => /\.[A-Za-z0-9]+$/.test(e.name)).map((e) => extensionOf(e.name).toLowerCase()))].sort(compareText);
|
|
@@ -2785,7 +2971,7 @@ export default defineConfig({
|
|
|
2785
2971
|
`;
|
|
2786
2972
|
out += ` data: { site: ${JSON.stringify(sortedKeys(site))} },
|
|
2787
2973
|
`;
|
|
2788
|
-
const pluginCalls = [...url ? [`sitemapPlugin({ url: ${JSON.stringify(url)} })`] : [], ...redirects ? [`redirectsPlugin({ redirects: ${JSON.stringify(redirects)} })`] : [], config.strict === true ? "linksPlugin()" : "linksPlugin({ fail: false })"];
|
|
2974
|
+
const pluginCalls = ["fromMkdocs()", ...url ? [`sitemapPlugin({ url: ${JSON.stringify(url)} })`] : [], ...redirects ? [`redirectsPlugin({ redirects: ${JSON.stringify(redirects)} })`] : [], config.strict === true ? "linksPlugin()" : "linksPlugin({ fail: false })"];
|
|
2789
2975
|
out += ` plugins: [${pluginCalls.join(", ")}],
|
|
2790
2976
|
});
|
|
2791
2977
|
`;
|
|
@@ -2816,6 +3002,10 @@ ${open}<pre><span></span><code>{% if fence.highlighted %}{{ fence.highlighted |
|
|
|
2816
3002
|
plan.newFiles.push(["_data/nav.yml", `the nav from ${configFile} (${entries2} entries), for \`navTree\``, `# From ${configFile}'s nav, by ssqch scout: titles as the nav gives them, or each page's first heading.
|
|
2817
3003
|
${dumpYaml(nav)}`]);
|
|
2818
3004
|
} else plan.byHand.push([configFile, "no `nav`: MkDocs builds the sidebar from the folders; ssqch's is `_data/nav.yml` (`navTree`) or `pagesTree(collections.all)`", { code: "mkdocs-nav", status: "ssqch", docs: "navTree" }]);
|
|
3005
|
+
for (const entry of plan.byHand) {
|
|
3006
|
+
const meta = entry[2];
|
|
3007
|
+
if (meta?.option && /admonitions: "mkdocs"|tabs: "mkdocs"|sourceLinks: "relative"|headingIds: "python-markdown"|dialect: "python-markdown"/.test(meta.option)) entry[2] = { ...meta, defines: ["plugin:fromMkdocs", ...meta.defines ?? []] };
|
|
3008
|
+
}
|
|
2819
3009
|
return plan;
|
|
2820
3010
|
}
|
|
2821
3011
|
function dumpYaml(nav, indent = "") {
|
|
@@ -2831,7 +3021,7 @@ ${dumpYaml(entry.children, `${indent} `)}`;
|
|
|
2831
3021
|
}
|
|
2832
3022
|
return out;
|
|
2833
3023
|
}
|
|
2834
|
-
var TRAILHEADS = { docusaurus: "from-docusaurus", hexo: "from-hexo", astro: "from-component-frameworks", vitepress: "from-
|
|
3024
|
+
var TRAILHEADS = { docusaurus: "from-docusaurus", hexo: "from-hexo", astro: "from-component-frameworks", vitepress: "from-vitepress" };
|
|
2835
3025
|
function countIn(entries, pattern) {
|
|
2836
3026
|
let count = 0;
|
|
2837
3027
|
let first;
|
|
@@ -2861,6 +3051,187 @@ function packagesLike(dir, pattern) {
|
|
|
2861
3051
|
}
|
|
2862
3052
|
}
|
|
2863
3053
|
var SKIP_BUILT = (name) => name.startsWith(".git") || name === "node_modules" || name === ".cache" || name === "build" || name === "dist" || name === ".docusaurus" || name === ".astro";
|
|
3054
|
+
var VITEPRESS_CONFIGS = [".vitepress/config.ts", ".vitepress/config.mts", ".vitepress/config.js", ".vitepress/config.mjs", "docs/.vitepress/config.ts", "docs/.vitepress/config.mts", "docs/.vitepress/config.js", "docs/.vitepress/config.mjs"];
|
|
3055
|
+
function prose(text) {
|
|
3056
|
+
return text.replace(/^([ \t]*)(`{3,}|~{3,})[^\n]*\n[\s\S]*?^\1\2[ \t]*$/gm, (m) => m.replace(/[^\n]/g, " ")).replace(/`[^`\n]+`/g, (m) => " ".repeat(m.length));
|
|
3057
|
+
}
|
|
3058
|
+
var vitepressGlob = (glob) => new RegExp(`^${glob.replace(/[.+^$()|[\]\\]/g, "\\$&").replace(/\*\*\/?/g, "\0").replace(/\*/g, "[^/]*").replace(/\0/g, ".*")}$`);
|
|
3059
|
+
function vitepress(dir) {
|
|
3060
|
+
const plan = { from: "VitePress", renames: [], edits: [], newFiles: [], byHand: [] };
|
|
3061
|
+
const configFile = VITEPRESS_CONFIGS.find((f) => isFile(path.join(dir, f)));
|
|
3062
|
+
const configText = configFile === void 0 ? "" : blankComments(readUtf8(path.join(dir, configFile)) ?? "");
|
|
3063
|
+
const root = configFile?.startsWith("docs/") ? "docs" : ".";
|
|
3064
|
+
const fromRoot = (rel) => (root === "." ? rel : `${root}/${rel}`).replace(/^\.\//, "").replace(/\/\.$/, "") || ".";
|
|
3065
|
+
const srcSetting = /\bsrcDir\s*:\s*["'`]([^"'`]+)["'`]/.exec(configText)?.[1]?.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
3066
|
+
const src = fromRoot(srcSetting ?? ".");
|
|
3067
|
+
const excludes = [...(/\bsrcExclude\s*:\s*\[([^\]]*)\]/.exec(configText)?.[1] ?? "").matchAll(/["'`]([^"'`]+)["'`]/g)].map((m) => m[1]);
|
|
3068
|
+
const excluded = excludes.map(vitepressGlob);
|
|
3069
|
+
const inSrc = (rel) => src === "." || rel.startsWith(`${src}/`);
|
|
3070
|
+
const fromSrc = (rel) => src === "." ? rel : rel.slice(src.length + 1);
|
|
3071
|
+
const entries = walk(dir, (n, rel) => SKIP_BUILT(n) || /(?:^|\/)\.vitepress\/(?:cache|dist)$/.test(rel), false).filter((e) => e.isFile && inSrc(e.rel));
|
|
3072
|
+
const isPage = (e) => /\.md$/i.test(e.name) && !/(?:^|\/)(?:\.vitepress|public|node_modules)\//.test(fromSrc(e.rel)) && !excluded.some((re) => re.test(fromSrc(e.rel)));
|
|
3073
|
+
const pages = entries.filter(isPage);
|
|
3074
|
+
plan.pages = pages.filter((e) => !/\[[^\]]+\]\.md$/.test(e.name)).length;
|
|
3075
|
+
const texts = new Map(pages.map((e) => [e.rel, readUtf8(e.abs) ?? ""]));
|
|
3076
|
+
const proseOf = new Map([...texts].map(([rel, text]) => [rel, prose(text)]));
|
|
3077
|
+
const includes = `${src === "." ? "" : `${src}/`}_includes`;
|
|
3078
|
+
const where = (rel, text, index) => `${rel}:${occurrences(text.slice(0, index), "\n") + 1}`;
|
|
3079
|
+
const count = (pattern, inProse = true) => {
|
|
3080
|
+
let n = 0;
|
|
3081
|
+
let first;
|
|
3082
|
+
const files = /* @__PURE__ */ new Set();
|
|
3083
|
+
for (const [rel, text] of inProse ? proseOf : texts) {
|
|
3084
|
+
for (const m of text.matchAll(new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`))) {
|
|
3085
|
+
n++;
|
|
3086
|
+
files.add(rel);
|
|
3087
|
+
first ??= where(rel, text, m.index);
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
return { n, files: files.size, first };
|
|
3091
|
+
};
|
|
3092
|
+
const dialect = 'markdown: { dialect: "vitepress" }';
|
|
3093
|
+
const item = (pattern, what, say, todo, inProse = true) => {
|
|
3094
|
+
const { n, files, first } = count(pattern, inProse);
|
|
3095
|
+
const own = todo.option === dialect ? { defines: ["plugin:fromVitepress", ...todo.defines ?? []] } : {};
|
|
3096
|
+
if (first) plan.byHand.push([first, `${what} (${uses(n, files)}): ${say}`, { ...todo, ...own, count: n, files }]);
|
|
3097
|
+
};
|
|
3098
|
+
item(/^<script\b[^>]*>/m, "Vue's `<script setup>` and `<script>` blocks in pages", "VitePress compiles them and writes none of it; `fromVitepress()` leaves them out (the components they import are listed one by one)", { code: "vitepress-script-setup", status: "option", option: dialect });
|
|
3099
|
+
item(/^<style\b[^>]*>/m, "`<style>` blocks in pages", "left out by `fromVitepress()`; put the CSS in the site's stylesheet", { code: "vitepress-style", status: "option", option: dialect });
|
|
3100
|
+
item(/<ClientOnly>/, "`<ClientOnly>`", "renders nothing on the server: `fromVitepress()` leaves it out; what's inside needs JavaScript in the browser (a custom element from `ssqch/elements`)", { code: "vitepress-client-only", status: "option", option: dialect });
|
|
3101
|
+
item(/^[ \t]{1,3}:{3,}[ \t]*$/m, "a container's closing `:::` indented under a list (Prettier's)", "markdown-it-container closes the container there, and so does ssqch's `:::`", { code: "vitepress-indented-container", status: "option", option: dialect });
|
|
3102
|
+
item(/^:::+\s*(?:tip|info|warning|danger|details|raw)\b/m, "containers (`::: tip`)", "VitePress's markup and default titles, built into `fromVitepress()`", { code: "vitepress-containers", status: "option", option: dialect });
|
|
3103
|
+
item(/^:::+\s*code-group\b/m, "code groups (`::: code-group`)", "built into `fromVitepress()`", { code: "vitepress-code-group", status: "option", option: dialect });
|
|
3104
|
+
item(/^\s*(?:`{3,}|~{3,})\s*[\w-]+-vue\b/m, "`-vue` fences (Vue's `{{ }}` evaluated in them)", "`fromVitepress()` prints their string literals; anything else stays as written", { code: "vitepress-vue-fences", status: "option", option: dialect }, false);
|
|
3105
|
+
item(/^\[\[toc\]\]\s*$/im, "`[[toc]]`", "markdown-it-table-of-contents' list, built into `fromVitepress()`", { code: "vitepress-toc", status: "option", option: dialect });
|
|
3106
|
+
item(/^<<<\s*@\//m, "`<<< @/` code snippets from files", "not in ssqch yet as written: an include in a template engine, or the code copied into a fence", { code: "vitepress-snippets", status: "not-yet" });
|
|
3107
|
+
item(/\{\{[^}]*\}\}/, "Vue interpolations in pages (`{{ count }}`, `{{ $frontmatter.title }}`)", 'Vue renders these; with `markdownEngine: false` (in the draft) ssqch prints them as written. Write the text itself, or move the part into a `.vue` component of its own that `vuePlugin()` renders (`ssqch docs "inline vue in pages"`)', { code: "vitepress-interpolations", status: "site", docs: "inline vue in pages" });
|
|
3108
|
+
item(/^<(?![A-Z])[a-z][\w-]*\b[^>\n]*\s(?:v-[\w:-]+|@[\w.-]+)(?:=|[\s>])/m, "Vue directives on HTML in pages (`v-if`, `@click`)", "they do something in the browser that ssqch's HTML doesn't: a custom element from `ssqch/elements` for that part", { code: "vitepress-directives", status: "site" });
|
|
3109
|
+
const used = /* @__PURE__ */ new Map();
|
|
3110
|
+
for (const [rel, text] of proseOf) {
|
|
3111
|
+
for (const m of text.matchAll(/<([A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*)(?=[\s/>])/g)) {
|
|
3112
|
+
if (m[1] === "ClientOnly") continue;
|
|
3113
|
+
const u = used.get(m[1]) ?? { n: 0, files: /* @__PURE__ */ new Set(), first: where(rel, text, m.index) };
|
|
3114
|
+
u.n++;
|
|
3115
|
+
u.files.add(rel);
|
|
3116
|
+
used.set(m[1], u);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
const sources = /* @__PURE__ */ new Map();
|
|
3120
|
+
for (const [rel, text] of texts) {
|
|
3121
|
+
for (const m of text.matchAll(/import\s+([A-Z]\w*)\s+from\s+['"]([^'"]+\.vue)['"]/g)) if (!sources.has(m[1])) sources.set(m[1], path.posix.normalize(path.posix.join(path.posix.dirname(rel), m[2])));
|
|
3122
|
+
}
|
|
3123
|
+
const themeIndex = [".vitepress/theme/index.ts", ".vitepress/theme/index.js", ".vitepress/theme/index.mts"].map(fromRoot).find((f) => isFile(path.join(dir, f)));
|
|
3124
|
+
const themeText = themeIndex === void 0 ? "" : readUtf8(path.join(dir, themeIndex)) ?? "";
|
|
3125
|
+
const themeGlobals = /* @__PURE__ */ new Map();
|
|
3126
|
+
for (const m of themeText.matchAll(/app\.component\(\s*['"](\w+)['"]\s*,\s*(\w+)/g)) {
|
|
3127
|
+
const imported = new RegExp(`import\\s+${m[2]}\\s+from\\s+['"]([^'"]+)['"]`).exec(themeText)?.[1];
|
|
3128
|
+
const file = imported === void 0 ? void 0 : imported.startsWith(".") ? path.posix.normalize(path.posix.join(path.posix.dirname(themeIndex), imported)) : imported;
|
|
3129
|
+
if (file !== void 0) themeGlobals.set(m[1], file);
|
|
3130
|
+
if (file !== void 0 && !sources.has(m[1])) sources.set(m[1], file);
|
|
3131
|
+
}
|
|
3132
|
+
let stateful = false;
|
|
3133
|
+
for (const [name, u] of [...used].sort(([a, x], [b, y]) => y.files.size - x.files.size || y.n - x.n || compareText(a, b))) {
|
|
3134
|
+
const from = sources.get(name);
|
|
3135
|
+
const vue = from !== void 0 && from.endsWith(".vue") ? readUtf8(path.join(dir, ...from.split("/"))) : void 0;
|
|
3136
|
+
const state = vue !== void 0 && /\b(?:ref|reactive|computed|onMounted|watch)\s*\(|v-model|@click|v-on:/.test(vue);
|
|
3137
|
+
if (state) stateful = true;
|
|
3138
|
+
const known = from !== void 0 && from.endsWith(".vue");
|
|
3139
|
+
const say = !known ? "a template for its HTML: `_includes/components/" + name + ".*` gets `component.props` and `component.content`" : state ? 'it has state (it runs in the browser): `vuePlugin()` from "ssqch/vue" renders it with Vue, and `hydrate` runs it in the browser too (both in the draft); or a template for its HTML and a custom element from `ssqch/elements` for what it does' : '`vuePlugin()` from "ssqch/vue" renders it with Vue (in the draft); or a template for its HTML, `_includes/components/' + name + ".*`, which gets `component.props` and `component.content`";
|
|
3140
|
+
plan.byHand.push([u.first, `\`<${name}>\`${from ? ` (${from})` : ""} (${uses(u.n, u.files.size)}): ${say}`, { code: "vitepress-component", status: known ? "ssqch" : "site", count: u.n, files: u.files.size, docs: known ? "vuePlugin" : "components", defines: [`file:${includes}/components/${name}.*`, ...known ? ["plugin:ssqch/vue"] : []] }]);
|
|
3141
|
+
}
|
|
3142
|
+
const keys = [["layout", "layout: home and page: the theme's; ssqch's `layout` names a template, so give these pages one (`layout: home.jinja`)"], ["hero", "the home layout's"], ["features", "the home layout's"], ["aside", "the layout's"], ["outline", "the layout's (`toc()` makes it)"], ["sidebar", "the layout's"], ["footer", "the layout's"], ["editLink", "the layout's"], ["prev", "the pager's"], ["next", "the pager's"], ["lastUpdated", 'the layout\'s (`lastModified: "git"`)']];
|
|
3143
|
+
for (const [key, say] of keys) {
|
|
3144
|
+
const files = [...texts].filter(([, t]) => new RegExp(`^---[\\s\\S]*?^${key}\\s*:[\\s\\S]*?^---`, "m").test(t)).map(([rel]) => rel);
|
|
3145
|
+
if (files.length) plan.byHand.push([files[0], `\`${key}\` front matter (in ${files.length} ${files.length === 1 ? "page" : "pages"}; this is the first): ${say}; a layout reads it as \`${key}\``, { code: "vitepress-front-matter", status: "site", files: files.length, defines: [`reads:${includes}:${key}`] }]);
|
|
3146
|
+
}
|
|
3147
|
+
const pageKey = [...texts].filter(([, t]) => /^---[\s\S]*?^page\s*:\s*true\b[\s\S]*?^---/m.test(t)).map(([rel]) => rel);
|
|
3148
|
+
if (pageKey.length) plan.byHand.push([pageKey[0], `\`page: true\` (in ${pageKey.length} ${pageKey.length === 1 ? "page" : "pages"}; this is the first): a page without the docs layout. \`page\` is ssqch's own, so it's replaced (and warned about): give these pages a layout of their own instead`, { code: "vitepress-page", status: "site", files: pageKey.length }]);
|
|
3149
|
+
const loaders = entries.filter((e) => /\.data\.[cm]?[jt]s$/.test(e.name));
|
|
3150
|
+
if (loaders.length) {
|
|
3151
|
+
const named = loaders.filter((e) => {
|
|
3152
|
+
const folder = path.posix.basename(path.posix.dirname(e.rel));
|
|
3153
|
+
return e.name.startsWith(`${folder}.data.`) || pages.some((p) => p.rel === e.rel.replace(/\.data\.[cm]?[jt]s$/, ".md"));
|
|
3154
|
+
});
|
|
3155
|
+
plan.byHand.push([loaders[0].rel, `${loaders.length} VitePress data ${loaders.length === 1 ? "loader" : "loaders"} (\`*.data.ts\`)${named.length ? `, ${named.length} named like a folder's or a page's data, which ssqch would read as data` : ""}: \`ignore\` lists them (in the draft), by their paths, so the data files the move adds stay ssqch's. \`vuePlugin()\` runs them for the components and pages that import their \`data\`, as VitePress does`, { code: "vitepress-loaders", status: "option", files: loaders.length, defines: [`has:ignore:${fromSrc(loaders[0].rel)}`] }]);
|
|
3156
|
+
}
|
|
3157
|
+
for (const route of pages.filter((e) => /\[[^\]]+\]\.md$/.test(e.name))) {
|
|
3158
|
+
const paths = entries.find((e) => e.rel === route.rel.replace(/\.md$/, ".paths.ts") || e.rel === route.rel.replace(/\.md$/, ".paths.js"));
|
|
3159
|
+
plan.byHand.push([route.rel, `a dynamic route${paths ? ` (its pages from ${paths.rel})` : ""}: in ssqch, \`pagination\` over the same list, with \`size: 1\`, a \`permalink\` with the item's value, and \`addAllPagesToCollections: true\`, in a \`.data.js\` beside it (\`ssqch docs pagination\`)`, { code: "vitepress-dynamic-route", status: "site", docs: "pagination", defines: [`file:${route.rel.replace(/\.md$/, ".data.*")}`] }]);
|
|
3160
|
+
}
|
|
3161
|
+
if (configFile !== void 0) {
|
|
3162
|
+
const clean = /\bcleanUrls\s*:\s*true\b/.test(configText);
|
|
3163
|
+
if (!clean) plan.byHand.push([configFile, '`cleanUrls` is off (VitePress\'s default), so pages are `/guide/intro.html`: `urls: "html"` (in the draft)', { code: "vitepress-urls", status: "option", option: 'urls: "html"' }]);
|
|
3164
|
+
const hostname = /\bsitemap\s*:\s*\{[^}]*\bhostname\s*:\s*["'`]([^"'`]+)["'`]/.exec(configText)?.[1];
|
|
3165
|
+
if (hostname) plan.byHand.push([configFile, `\`sitemap\`: \`sitemapPlugin({ url: "${hostname}" })\` (in the draft) lists the same URLs; the file is ssqch's own, so \`ssqch diff\` shows sitemap.xml as changed`, { code: "vitepress-sitemap", status: "ssqch", defines: ["plugin:ssqch/sitemap"] }]);
|
|
3166
|
+
const head = /\bhead\s*:\s*\[/.exec(configText);
|
|
3167
|
+
if (head) {
|
|
3168
|
+
const close = closingBracket(configText, head.index + head[0].length - 1);
|
|
3169
|
+
const body = close === void 0 ? "" : configText.slice(head.index, close);
|
|
3170
|
+
const tags = (body.match(/\[\s*["'`](?:meta|link|script|style)["'`]/g) ?? []).length;
|
|
3171
|
+
if (tags) plan.byHand.push([configFile, `\`head\` (${tags} ${tags === 1 ? "tag" : "tags"}${/["'`]script["'`]/.test(body) ? ", scripts among them" : ""}): VitePress writes them into every page's \`<head>\`; put them in the layout`, { code: "vitepress-head", status: "site", count: tags, defines: [`reads:${includes}:<head`] }]);
|
|
3172
|
+
}
|
|
3173
|
+
for (const m of configText.matchAll(/\bmd\.use\(\s*([\w$]+)/g)) plan.byHand.push([configFile, `\`md.use(${m[1]})\`: a markdown-it plugin of the site's (or a package's). In ssqch, what it writes is a render hook, a container, or \`markdown.preprocess\``, { code: "vitepress-markdown-plugin", status: "site", defines: [`file:${includes}/hooks/heading.*`, `file:${includes}/hooks/link.*`, `file:${includes}/hooks/fence.*`, "markdown.preprocess"] }]);
|
|
3174
|
+
if (/\bthemeConfig\b[\s\S]*\b(?:sidebar|nav)\s*:/.test(configText)) plan.byHand.push([configFile, "`themeConfig`'s `nav` and `sidebar`: data for ssqch's layout. Move them to a `_data/*.js` file that the VitePress config imports too, so both read one list; `navTree` marks the page you're on (a sidebar keyed by path picks the longest key that the page's URL starts with)", { code: "vitepress-sidebar", status: "site", docs: "navTree" }]);
|
|
3175
|
+
}
|
|
3176
|
+
for (const pkg of packagesLike(dir, /^vitepress-plugin-|^@?[\w-]*\/?vitepress-plugin-/)) {
|
|
3177
|
+
const say = /llms/.test(pkg) ? '`llms.txt`, a Markdown copy of each page and `llms-full.txt`: `llmsPlugin()` from "ssqch/llms"' : /group-icons/.test(pkg) ? "icons on code groups' tabs: its CSS keyed by the tab's label (`data-title`), which `fromVitepress()` writes" : "not in ssqch yet: port what it does as a hook, a transform or a plugin";
|
|
3178
|
+
plan.byHand.push(["package.json", `${pkg}: ${say}`, { code: "vitepress-plugin", status: /group-icons|llms/.test(pkg) ? "ssqch" : "site", .../llms/.test(pkg) ? { defines: ["plugin:ssqch/llms"] } : {} }]);
|
|
3179
|
+
}
|
|
3180
|
+
if (themeIndex !== void 0) {
|
|
3181
|
+
const extendsDefault = /\bextends\s*:\s*DefaultTheme\b|from\s+['"]vitepress\/theme['"]/.test(themeText);
|
|
3182
|
+
const slots = [...themeText.matchAll(/['"]?([a-z][\w-]*)['"]?\s*:\s*\(\)\s*=>\s*h\(/g)].map((m) => m[1]);
|
|
3183
|
+
plan.byHand.push([themeIndex, `a ${extendsDefault ? "theme that extends VitePress's default one" : "custom theme"}${slots.length ? ` (with ${slots.map((sl) => `\`${sl}\``).join(", ")} slots)` : ""}: keep it, rendered by \`vuePlugin()\` around each page, with a wrapper component and a layout (\`ssqch docs "keeping your vitepress theme"\`); or rebuild the layout as a template from the reference build's HTML, with \`navTree\`, \`navPager\` and \`toc()\``, { code: "vitepress-theme", status: "site", docs: "keeping your vitepress theme", defines: [`reads:${includes}:<html`] }]);
|
|
3184
|
+
}
|
|
3185
|
+
const publicDir = src === "." ? "public" : `${src}/public`;
|
|
3186
|
+
if (isDir(path.join(dir, ...publicDir.split("/")))) plan.byHand.push([publicDir, `\`public/\`, copied to the site's root: \`passthrough: { "${publicDir}/**": "." }\` (in the draft; \`{ "${publicDir}": "." }\` would copy the folder by its name)`, { code: "vitepress-public", status: "option", defines: [`passthrough`] }]);
|
|
3187
|
+
if (configFile !== void 0) {
|
|
3188
|
+
const hostname = /\bsitemap\s*:\s*\{[^}]*\bhostname\s*:\s*["'`]([^"'`]+)["'`]/.exec(configText)?.[1];
|
|
3189
|
+
const clean = /\bcleanUrls\s*:\s*true\b/.test(configText);
|
|
3190
|
+
const ignore = [...loaders.map((e) => fromSrc(e.rel)), ...excludes, ".vitepress/**", "public/**"].map((g) => JSON.stringify(g));
|
|
3191
|
+
const vueGlobals = [...themeGlobals].filter(([name]) => used.has(name) && themeGlobals.get(name).endsWith(".vue"));
|
|
3192
|
+
const vue = [...used.keys()].some((name) => sources.get(name)?.endsWith(".vue"));
|
|
3193
|
+
const llms = packagesLike(dir, /vitepress-plugin-llms/).length > 0;
|
|
3194
|
+
const siteTitle = /\btitle\s*:\s*["'`]([^"'`]+)["'`]/.exec(configText)?.[1];
|
|
3195
|
+
const siteDescription = /\bdescription\s*:\s*["'`]([^"'`]+)["'`]/.exec(configText)?.[1];
|
|
3196
|
+
const lines2 = [
|
|
3197
|
+
`// A first draft, from ${configFile} (\`ssqch scout\`): VitePress's pages and Markdown. The layout,`,
|
|
3198
|
+
"// the components and the theme's CSS are the move's own; `ssqch scout` lists them.",
|
|
3199
|
+
...hostname ? ['import { sitemapPlugin } from "ssqch/sitemap";'] : [],
|
|
3200
|
+
...vue ? ['import { vuePlugin } from "ssqch/vue";'] : [],
|
|
3201
|
+
...llms ? ['import { llmsPlugin } from "ssqch/llms";'] : [],
|
|
3202
|
+
'import { fromVitepress } from "ssqch/from-vitepress";',
|
|
3203
|
+
"",
|
|
3204
|
+
"export default {",
|
|
3205
|
+
` dirs: { input: ${JSON.stringify(src)}, output: "dist" },`,
|
|
3206
|
+
" // VitePress's pages are its Markdown, and Vue's `{{ }}` in them isn't a template language's.",
|
|
3207
|
+
' templateFormats: ["md"],',
|
|
3208
|
+
" markdownEngine: false,",
|
|
3209
|
+
...clean ? [] : [" // `cleanUrls` is off: /guide/intro.html.", ' urls: "html",'],
|
|
3210
|
+
" // VitePress's data loaders, `srcExclude`, its own folder, and `public/` (copied below).",
|
|
3211
|
+
` ignore: [${ignore.join(", ")}],`,
|
|
3212
|
+
...isDir(path.join(dir, ...publicDir.split("/"))) ? [` passthrough: { ${JSON.stringify(`${publicDir}/**`)}: "." },`] : [],
|
|
3213
|
+
" markdown: { highlight: true },",
|
|
3214
|
+
...[
|
|
3215
|
+
" plugins: [",
|
|
3216
|
+
" // VitePress's Markdown: its containers, headings, links, code blocks and `[[toc]]`.",
|
|
3217
|
+
" fromVitepress(),",
|
|
3218
|
+
...vue ? [
|
|
3219
|
+
" // The Vue components the pages use, rendered with the site's Vite and Vue (and run in the browser with `hydrate`).",
|
|
3220
|
+
` vuePlugin({ ${vueGlobals.length ? `components: { ${vueGlobals.map(([n, f]) => `${n}: ${JSON.stringify(f)}`).join(", ")} }${stateful ? ", " : ""}` : ""}${stateful ? 'hydrate: "visible"' : ""} }),`
|
|
3221
|
+
] : [],
|
|
3222
|
+
...hostname ? [` sitemapPlugin({ url: ${JSON.stringify(hostname)} }),`] : [],
|
|
3223
|
+
...llms ? [` llmsPlugin({ ${[siteTitle ? `title: ${JSON.stringify(siteTitle)}` : "", siteDescription ? `description: ${JSON.stringify(siteDescription)}` : "", hostname ? `url: ${JSON.stringify(hostname)}` : ""].filter(Boolean).join(", ")} }),`] : [],
|
|
3224
|
+
" ],"
|
|
3225
|
+
],
|
|
3226
|
+
"};",
|
|
3227
|
+
""
|
|
3228
|
+
];
|
|
3229
|
+
plan.newFiles.push(["ssqch.config.js", `a first draft, from ${configFile}`, lines2.join("\n")]);
|
|
3230
|
+
} else {
|
|
3231
|
+
plan.byHand.push([".", `no VitePress config here (${VITEPRESS_CONFIGS.slice(0, 4).join(", ")}): is this the site's folder?`]);
|
|
3232
|
+
}
|
|
3233
|
+
return plan;
|
|
3234
|
+
}
|
|
2864
3235
|
function other(dir, id) {
|
|
2865
3236
|
const name = GENERATORS[id].name;
|
|
2866
3237
|
const plan = { from: name, renames: [], edits: [], newFiles: [], byHand: [] };
|
|
@@ -2890,19 +3261,6 @@ function other(dir, id) {
|
|
|
2890
3261
|
if (collections) plan.byHand.push([collections, "content collections with schemas: ssqch's are collections and `schemas` (`ssqch docs schemas`)", { code: "astro-content-collections", status: "ssqch", docs: "schemas" }]);
|
|
2891
3262
|
listSyntax(plan, pages, [["`import` in MDX pages", /^import\s+.+\s+from\s+['"][^'"]+['"]/m, "not in ssqch yet as written: Edge components or containers", "astro-mdx-imports", "not-yet"]]);
|
|
2892
3263
|
for (const pkg of packagesLike(dir, /^@astrojs\//)) plan.byHand.push(["package.json", `${pkg}: ${/sitemap/.test(pkg) ? '`sitemapPlugin()` from "ssqch/sitemap"' : /mdx/.test(pkg) ? "MDX pages: see the MDX line" : /rss/.test(pkg) ? '`rssPlugin()` from "ssqch/rss"' : /react|vue|svelte|preact|solid/.test(pkg) ? "framework islands: custom elements" : "not in ssqch yet: port it as a plugin"}`, { code: "astro-integration", status: /sitemap|rss/.test(pkg) ? "ssqch" : "site" }]);
|
|
2893
|
-
} else if (id === "vitepress") {
|
|
2894
|
-
listSyntax(plan, pages, [
|
|
2895
|
-
["containers (`::: tip`)", /^:::\s*(?:tip|info|warning|danger|details)\b/m, "containers, built in: `_includes/containers/tip.*` gives each its markup", "vitepress-containers", "ssqch"],
|
|
2896
|
-
["code groups (`::: code-group`)", /^:::\s*code-group\b/m, "a container with a template of its own", "vitepress-code-group", "ssqch"],
|
|
2897
|
-
["Vue components in pages", /^<[A-Z][\w-]*[\s/>]/m, "not in ssqch yet as written: custom elements, or Edge components", "vitepress-vue", "not-yet"],
|
|
2898
|
-
["Vue expressions (`{{ $frontmatter.x }}`)", /\{\{\s*\$\w+/, "template code: with `markdownEngine` on, ssqch's templates read front matter as `{{ x }}`", "vitepress-expressions", "site"],
|
|
2899
|
-
["`[[toc]]`", /^\[\[toc\]\]\s*$/m, "the `toc` filter in the layout, from `page.headings`", "vitepress-toc", "ssqch"],
|
|
2900
|
-
["`<<< @/` snippets", /^<<<\s*@\//m, "not in ssqch yet as written: an include in a template engine", "vitepress-snippets", "not-yet"]
|
|
2901
|
-
]);
|
|
2902
|
-
const config = [".vitepress/config.ts", ".vitepress/config.mts", ".vitepress/config.js", ".vitepress/config.mjs", "docs/.vitepress/config.ts", "docs/.vitepress/config.mts", "docs/.vitepress/config.js"].find((f) => isFile(path.join(dir, f)));
|
|
2903
|
-
if (config) plan.byHand.push([config, "the config's `sidebar` and `nav`: ssqch's are data (`_data/nav.yml`) and `navTree`", { code: "vitepress-sidebar", status: "ssqch", docs: "navTree" }]);
|
|
2904
|
-
const theme = entries.find((e) => /(?:^|\/)\.vitepress\/theme\/index\.[jt]s$/.test(e.rel));
|
|
2905
|
-
if (theme) plan.byHand.push([theme.rel, "a custom theme (Vue): ssqch's layouts are templates; the theme's components become templates and custom elements", { code: "vitepress-theme", status: "site" }]);
|
|
2906
3264
|
} else if (id === "hexo") {
|
|
2907
3265
|
listSyntax(plan, pages, [
|
|
2908
3266
|
["tag plugins (`{% codeblock %}`, `{% asset_img %}`, `{% post_link %}`)", /\{%\s*(?:codeblock|asset_img|asset_link|asset_path|post_link|post_path|blockquote|youtube|iframe|img|link|include_code|raw)\b/, "not in ssqch yet as written: filters or shortcodes of the site's own (Liquid's and Nunjucks' `{% %}` read them as tags)", "hexo-tag-plugins", "not-yet"],
|
|
@@ -2918,6 +3276,7 @@ function other(dir, id) {
|
|
|
2918
3276
|
export {
|
|
2919
3277
|
SEO_INCLUDE,
|
|
2920
3278
|
blankComments,
|
|
3279
|
+
definedIn,
|
|
2921
3280
|
detect,
|
|
2922
3281
|
draftConfig,
|
|
2923
3282
|
eleventy,
|
|
@@ -2941,5 +3300,7 @@ export {
|
|
|
2941
3300
|
tomlError,
|
|
2942
3301
|
unifiedHunks,
|
|
2943
3302
|
unwrapUrlLiterals,
|
|
3303
|
+
vitepress,
|
|
3304
|
+
withoutBlankAfterFrontMatter,
|
|
2944
3305
|
zola
|
|
2945
3306
|
};
|