dogsbay 0.2.0-beta.101 → 0.2.0-beta.103

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.
@@ -57,5 +57,16 @@ export interface MigrateAsciidocOptions {
57
57
  * loader uses this; other loaders ignore it.
58
58
  */
59
59
  topicMap?: string;
60
+ /**
61
+ * Content directory the source's images are copied into, and the root the
62
+ * emitted refs use. Defaults to `images` — the source's own directory name,
63
+ * which keeps the reference as short as it can be (`/images/foo.png`) and
64
+ * matches what someone hand-authoring would type.
65
+ *
66
+ * `site build` probes `images/`, `assets/` and `_assets/` and mounts
67
+ * whichever exists under its own name, so all three resolve. Pass
68
+ * `_assets` for the previous `/_assets/images/foo.png` form.
69
+ */
70
+ assetsRoot?: string;
60
71
  }
61
72
  export declare function migrateAsciidoc(source: string, options: MigrateAsciidocOptions): Promise<void>;
@@ -716,7 +716,24 @@ export async function migrateAsciidoc(source, options) {
716
716
  statSync(join(sourceDir, "images")).isDirectory()
717
717
  ? "images"
718
718
  : undefined;
719
- const engineImagesdir = srcImagesDir ? `/_assets/${srcImagesDir}` : undefined;
719
+ // Default `images` — the source's OWN directory name, and what a hand-author
720
+ // would type. `site build` probes images/ assets/ _assets/ and mounts
721
+ // whichever exists under its own name, so the simplest reference that works
722
+ // is the one the source already used. `--assets-root _assets` restores the
723
+ // previous `/_assets/images/...` form.
724
+ const assetsRoot = options.assetsRoot ?? "images";
725
+ // A single path segment, or the ref and the copy destination part company:
726
+ // an empty string is not nullish so it skips the default and yields
727
+ // `//images/foo.png` — a protocol-relative URL naming a host `images` —
728
+ // while the files land in content/images/. A `/` or `..` splits them too.
729
+ if (!/^[A-Za-z0-9._-]+$/.test(assetsRoot) || assetsRoot === "." || assetsRoot === "..") {
730
+ throw new Error(`--assets-root must be a single path segment (got ${JSON.stringify(assetsRoot)})`);
731
+ }
732
+ const engineImagesdir = srcImagesDir
733
+ ? assetsRoot === srcImagesDir
734
+ ? `/${srcImagesDir}`
735
+ : `/${assetsRoot}/${srcImagesDir}`
736
+ : undefined;
720
737
  const engineAttributes = engineImagesdir
721
738
  ? { ...attributes, imagesdir: engineImagesdir }
722
739
  : attributes;
@@ -933,11 +950,13 @@ export async function migrateAsciidoc(source, options) {
933
950
  // build. (#363)
934
951
  if (srcImagesDir) {
935
952
  const from = join(sourceDir, srcImagesDir);
936
- const to = join(contentDir, "_assets", srcImagesDir);
953
+ const to = assetsRoot === srcImagesDir
954
+ ? join(contentDir, srcImagesDir)
955
+ : join(contentDir, assetsRoot, srcImagesDir);
937
956
  try {
938
957
  mkdirSync(dirname(to), { recursive: true });
939
958
  cpSync(from, to, { recursive: true });
940
- console.log(pc.green(`Copied`) + ` images → content/_assets/${srcImagesDir}/`);
959
+ console.log(pc.green(`Copied`) + ` images → ${relative(outputDir, to)}/`);
941
960
  }
942
961
  catch (err) {
943
962
  const msg = err instanceof Error ? err.message : String(err);
package/dist/index.js CHANGED
@@ -314,6 +314,10 @@ program
314
314
  .option("--topic-map <path>", "AsciiBinder topic-map path, relative to the source root " +
315
315
  "(default: _topic_maps/_topic_map.yml). Drives loader detection and " +
316
316
  "loading for corpora that name their topic map differently.")
317
+ .option("--assets-root <name>", "Content directory images are copied into, and the root emitted refs use " +
318
+ "(default: images — the source's own dir name, giving /images/foo.png). " +
319
+ "site build resolves images/, assets/ and _assets/ alike; pass _assets " +
320
+ "for the previous /_assets/images/foo.png form.")
317
321
  .option("--local", "Use file: references to local monorepo packages (for development)")
318
322
  .option("--quiet", "Suppress the 'Next steps' trailer")
319
323
  .action((source, options) => migrateAsciidoc(source, options));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dogsbay",
3
- "version": "0.2.0-beta.101",
3
+ "version": "0.2.0-beta.103",
4
4
  "description": "CLI for Dogsbay — scaffold, build, and serve documentation sites with markdown / MkDocs / Obsidian / OpenAPI sources",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,32 +42,32 @@
42
42
  "typescript": "^5.9.3",
43
43
  "valibot": "1.1.0",
44
44
  "yaml": "^2.9.0",
45
- "@dogsbay/adoc2md-modular": "0.2.0-beta.101",
46
- "@dogsbay/autodoc-python": "0.2.0-beta.101",
47
- "@dogsbay/commands": "0.2.0-beta.101",
48
- "@dogsbay/format-asciidoc": "0.2.0-beta.101",
49
- "@dogsbay/format-astro": "0.2.0-beta.101",
50
- "@dogsbay/format-dita": "0.2.0-beta.101",
51
- "@dogsbay/format-docusaurus": "0.2.0-beta.101",
52
- "@dogsbay/format-dogsbay-md": "0.2.0-beta.101",
53
- "@dogsbay/format-fluidtopics-markdown": "0.2.0-beta.101",
54
- "@dogsbay/format-fluidtopics-rest": "0.2.0-beta.101",
55
- "@dogsbay/format-gatsby": "0.2.0-beta.101",
56
- "@dogsbay/format-gitbook": "0.2.0-beta.101",
57
- "@dogsbay/format-hugo": "0.2.0-beta.101",
58
- "@dogsbay/format-mdx": "0.2.0-beta.101",
59
- "@dogsbay/format-myst": "0.2.0-beta.101",
60
- "@dogsbay/format-mkdocs": "0.2.0-beta.101",
61
- "@dogsbay/format-obsidian": "0.2.0-beta.101",
62
- "@dogsbay/format-openapi": "0.2.0-beta.101",
63
- "@dogsbay/format-openknowledge": "0.2.0-beta.101",
64
- "@dogsbay/format-rst": "0.2.0-beta.101",
65
- "@dogsbay/format-starlight": "0.2.0-beta.101",
66
- "@dogsbay/format-topicmap": "0.2.0-beta.101",
67
- "@dogsbay/minja": "0.2.0-beta.101",
68
- "@dogsbay/format-vitepress": "0.2.0-beta.101",
69
- "@dogsbay/serialize-core": "0.2.0-beta.101",
70
- "@dogsbay/types": "0.2.0-beta.101"
45
+ "@dogsbay/adoc2md-modular": "0.2.0-beta.103",
46
+ "@dogsbay/autodoc-python": "0.2.0-beta.103",
47
+ "@dogsbay/commands": "0.2.0-beta.103",
48
+ "@dogsbay/format-astro": "0.2.0-beta.103",
49
+ "@dogsbay/format-asciidoc": "0.2.0-beta.103",
50
+ "@dogsbay/format-dita": "0.2.0-beta.103",
51
+ "@dogsbay/format-docusaurus": "0.2.0-beta.103",
52
+ "@dogsbay/format-dogsbay-md": "0.2.0-beta.103",
53
+ "@dogsbay/format-fluidtopics-markdown": "0.2.0-beta.103",
54
+ "@dogsbay/format-fluidtopics-rest": "0.2.0-beta.103",
55
+ "@dogsbay/format-gitbook": "0.2.0-beta.103",
56
+ "@dogsbay/format-gatsby": "0.2.0-beta.103",
57
+ "@dogsbay/format-hugo": "0.2.0-beta.103",
58
+ "@dogsbay/format-mdx": "0.2.0-beta.103",
59
+ "@dogsbay/format-mkdocs": "0.2.0-beta.103",
60
+ "@dogsbay/format-myst": "0.2.0-beta.103",
61
+ "@dogsbay/format-obsidian": "0.2.0-beta.103",
62
+ "@dogsbay/format-openapi": "0.2.0-beta.103",
63
+ "@dogsbay/format-openknowledge": "0.2.0-beta.103",
64
+ "@dogsbay/format-rst": "0.2.0-beta.103",
65
+ "@dogsbay/format-starlight": "0.2.0-beta.103",
66
+ "@dogsbay/format-topicmap": "0.2.0-beta.103",
67
+ "@dogsbay/format-vitepress": "0.2.0-beta.103",
68
+ "@dogsbay/minja": "0.2.0-beta.103",
69
+ "@dogsbay/serialize-core": "0.2.0-beta.103",
70
+ "@dogsbay/types": "0.2.0-beta.103"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/markdown-it": "^14.1.2",