@dogsbay/format-vitepress 0.2.0-beta.133 → 0.2.0-beta.135

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/dist/import.d.ts CHANGED
@@ -24,5 +24,7 @@ export interface VitepressCorpusImport {
24
24
  components: Record<string, number>;
25
25
  /** Per-page constructs mapped with caveats, pages that failed, and the loader's warnings. */
26
26
  ledger: ImportLedgerEntry[];
27
+ /** The corpus file each page was converted from: `sources[i]` is `pages[i]`'s. */
28
+ sources: string[];
27
29
  }
28
30
  export declare function importVitepressCorpus(corpus: Corpus, opts?: VitepressLoadOptions): VitepressCorpusImport;
package/dist/import.js CHANGED
@@ -8,6 +8,7 @@ export function importVitepressCorpus(corpus, opts = {}) {
8
8
  const pages = [];
9
9
  const components = {};
10
10
  const ledger = [];
11
+ const sources = [];
11
12
  for (const ps of loaded.pages) {
12
13
  try {
13
14
  const content = corpus.text(ps.path);
@@ -30,6 +31,7 @@ export function importVitepressCorpus(corpus, opts = {}) {
30
31
  const heroName = typeof frontmatter.hero?.name === "string"
31
32
  ? (frontmatter.hero.name)
32
33
  : undefined;
34
+ sources.push(ps.path);
33
35
  pages.push({
34
36
  slug: ps.slug,
35
37
  title: fmTitle || h1?.text || heroName || titleFromSlug(ps.slug),
@@ -72,5 +74,6 @@ export function importVitepressCorpus(corpus, opts = {}) {
72
74
  warnings: loaded.warnings,
73
75
  components,
74
76
  ledger,
77
+ sources,
75
78
  };
76
79
  }
package/dist/migrate.js CHANGED
@@ -1,5 +1,5 @@
1
- import { corpusFromMap, unfetchedMessage } from "@dogsbay/corpus";
2
- import { dogsbayMdPageFiles, mountCopies } from "@dogsbay/format-dogsbay-md/browser";
1
+ import { corpusFromMap, pageSources, pendingCopies, unfetchedMessage, withPages } from "@dogsbay/corpus";
2
+ import { dogsbayMdPageFiles, dogsbayMdPagePath, mountCopies } from "@dogsbay/format-dogsbay-md/browser";
3
3
  import { importVitepressCorpus } from "./import.js";
4
4
  /** The ledger line for a conversion that still needs files, or nothing. */
5
5
  function unfetchedLedger(read, stoppedOn) {
@@ -53,31 +53,42 @@ export async function migrate(input) {
53
53
  // A file it needed was not given: that, not the error, is the answer
54
54
  const read = corpus.missing();
55
55
  if (read.length)
56
- return { files: new Map(), ledger: unfetchedLedger(read, e), unfetched: { read, copy: [] } };
56
+ return { files: new Map(), ledger: unfetchedLedger(read, e), unfetched: { read, copy: [], copyTo: [] } };
57
57
  throw e;
58
58
  }
59
59
  const siteName = input.siteName?.trim() || imported.siteName?.trim() || "Docs";
60
60
  const files = new Map();
61
61
  // Assets first, then the pages: `convert` copies the mounts before it writes the pages, so a
62
62
  // page wins over a file at the same path
63
+ const pageFiles = dogsbayMdPageFiles(imported.pages, imported.nav);
64
+ // One file per output path, the last mount's (public/ and .vitepress/public/ both land in
65
+ // _assets/), whether its bytes were given or not; a page at the same path wins
66
+ const winners = new Map();
67
+ for (const { from, to } of mountCopies(corpus.paths, imported.assetDirs))
68
+ winners.set(to, from);
63
69
  const copy = [];
64
- for (const { from, to } of mountCopies(corpus.paths, imported.assetDirs)) {
70
+ for (const [to, from] of winners) {
71
+ if (pageFiles.has(to))
72
+ continue;
65
73
  const bytes = input.files.get(from);
66
74
  if (bytes !== undefined)
67
75
  files.set(`content/${to}`, bytes);
68
76
  else
69
- copy.push(from);
77
+ copy.push({ from, to: `content/${to}` });
70
78
  }
71
- for (const [path, text] of dogsbayMdPageFiles(imported.pages, imported.nav))
79
+ for (const [path, text] of pageFiles)
72
80
  files.set(`content/${path}`, text);
81
+ // Each note about a page's file names the page written from it
82
+ const pageOf = pageSources(imported.pages.map((p, i) => ({ file: imported.sources[i], path: `content/${dogsbayMdPagePath(p)}` })));
83
+ const ledger = withPages(imported.ledger, pageOf);
73
84
  files.set("dogsbay.config.yml", buildConfig(siteName, input.siteUrl));
74
85
  files.set("MIGRATION.md", migrationNotes({
75
86
  siteName,
76
87
  sourceLabel: input.sourceLabel ?? "VitePress project",
77
88
  pages: imported.pages.length,
78
89
  navSource: imported.navSource,
79
- ledger: imported.ledger,
90
+ ledger,
80
91
  }));
81
92
  const read = corpus.missing();
82
- return { files, ledger: [...unfetchedLedger(read), ...imported.ledger], unfetched: { read, copy: copy.sort() } };
93
+ return { files, ledger: [...unfetchedLedger(read), ...ledger], unfetched: { read, ...pendingCopies(copy) } };
83
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/format-vitepress",
3
- "version": "0.2.0-beta.133",
3
+ "version": "0.2.0-beta.135",
4
4
  "description": "VitePress format plugin for Dogsbay — imports VitePress docs projects into TreeNode[] by translating VitePress containers, code-fence conventions, snippets and includes to Dogsbay-MD.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,11 +24,11 @@
24
24
  "README.md"
25
25
  ],
26
26
  "dependencies": {
27
- "@dogsbay/corpus": "0.2.0-beta.133",
28
- "@dogsbay/format-dogsbay-md": "0.2.0-beta.133",
29
- "@dogsbay/detect": "0.2.0-beta.133",
30
- "@dogsbay/literal": "0.2.0-beta.133",
31
- "@dogsbay/types": "0.2.0-beta.133"
27
+ "@dogsbay/corpus": "0.2.0-beta.135",
28
+ "@dogsbay/detect": "0.2.0-beta.135",
29
+ "@dogsbay/types": "0.2.0-beta.135",
30
+ "@dogsbay/format-dogsbay-md": "0.2.0-beta.135",
31
+ "@dogsbay/literal": "0.2.0-beta.135"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^25.9.5",