dogsbay 0.2.0-beta.40 → 0.2.0-beta.42

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.
@@ -131,15 +131,28 @@ export async function migrateMkdocs(source, options) {
131
131
  // makes the migrated config self-documenting. NO `output:`
132
132
  // field — the default (./astro) is what we want; flat layout
133
133
  // (`output: "."`) triggers a rebuild loop in `site dev`.
134
- const siteUrl = config.site_url || undefined;
134
+ // site.url is NOT inherited from the source mkdocs.yml. A
135
+ // migration almost always moves to a new host, so copying the
136
+ // source's site_url silently bakes the wrong origin into
137
+ // robots.txt, sitemap, canonical tags, and llms.txt. The user
138
+ // supplies the destination explicitly with --site-url; absent,
139
+ // site.url is left unset and the build emits relative URLs.
140
+ // sourceSiteUrl is kept only to warn the user it was dropped.
141
+ const sourceSiteUrl = config.site_url || undefined;
142
+ const siteUrl = options.siteUrl || undefined;
135
143
  const repoUrl = config.repo_url || undefined;
144
+ // --base-path controls where docs sit under the host. Default
145
+ // /docs (matches every scaffolded dogsbay site); pass --base-path
146
+ // "" to serve at the host root — common for a dedicated repo or
147
+ // GitHub Pages project site.
148
+ const basePath = options.basePath !== undefined ? options.basePath : "/docs";
136
149
  const siteDescription = config.site_description || undefined;
137
150
  const dogsbayConfig = {
138
151
  schemaVersion: 1,
139
152
  site: {
140
153
  name: siteName,
141
154
  url: siteUrl,
142
- basePath: "/docs",
155
+ basePath,
143
156
  description: siteDescription,
144
157
  repoUrl,
145
158
  },
@@ -153,6 +166,14 @@ export async function migrateMkdocs(source, options) {
153
166
  };
154
167
  writeFileSync(join(outputDir, "dogsbay.config.yml"), serializeConfig(dogsbayConfig, "yaml"));
155
168
  console.log(pc.green(`Wrote`) + ` dogsbay.config.yml`);
169
+ if (sourceSiteUrl && !siteUrl) {
170
+ console.log(pc.yellow(`Note:`) +
171
+ ` source site_url (${sourceSiteUrl}) was not carried over —` +
172
+ ` a migration moves hosts.`);
173
+ console.log(` Set site.url in dogsbay.config.yml (or re-run with` +
174
+ ` --site-url) so robots.txt,`);
175
+ console.log(` sitemap, and llms.txt point at your host.`);
176
+ }
156
177
  // 6. Scaffold the Astro project under ./astro/ (theme,
157
178
  // package.json, astro.config.mjs, tsconfig, copied UI
158
179
  // components). Same emitter `dogsbay site init` uses, just
@@ -160,7 +181,7 @@ export async function migrateMkdocs(source, options) {
160
181
  emitSiteScaffold(astroDir, siteName, {
161
182
  siteName,
162
183
  siteUrl,
163
- basePath: "/docs",
184
+ basePath,
164
185
  repoUrl,
165
186
  llmsTxt: true,
166
187
  mdMirror: true,
@@ -187,6 +208,9 @@ export async function migrateMkdocs(source, options) {
187
208
  pageCount,
188
209
  assetCount,
189
210
  lossy,
211
+ siteUrl,
212
+ sourceSiteUrl,
213
+ basePath,
190
214
  }));
191
215
  console.log(pc.green(`Wrote`) + ` MIGRATION.md`);
192
216
  if (!options.quiet) {
@@ -785,7 +809,7 @@ function labelFromPath(path) {
785
809
  }
786
810
  // ── MIGRATION.md ────────────────────────────────────────
787
811
  function buildMigrationNotes(args) {
788
- const { sourceDir, outputDir, siteName, pageCount, assetCount, lossy } = args;
812
+ const { sourceDir, outputDir, siteName, pageCount, assetCount, lossy, siteUrl, sourceSiteUrl, basePath, } = args;
789
813
  const lines = [
790
814
  `# Migration: ${siteName}`,
791
815
  "",
@@ -811,19 +835,22 @@ function buildMigrationNotes(args) {
811
835
  "npx dogsbay site dev # watch + preview",
812
836
  "```",
813
837
  "",
814
- "## Re-running the migration",
815
- "",
816
- "If you find a regression and we ship a fix, re-run with `--force`:",
817
- "",
818
- "```bash",
819
- `npx dogsbay migrate-mkdocs ${sourceDir} --output ${outputDir} --force`,
820
- "```",
821
- "",
822
- "Note that `--force` overwrites all generated files; any hand edits",
823
- "to `./content/*.md` since the last migration will be lost. Commit",
824
- "your work first.",
825
- "",
826
838
  ];
839
+ // Site URL section — the destination URL is not inherited from the
840
+ // source mkdocs.yml, so spell out what was written and what (if
841
+ // anything) was dropped.
842
+ lines.push("## Site URL", "");
843
+ if (siteUrl) {
844
+ lines.push(`\`site.url\` is set to \`${siteUrl}\` (from \`--site-url\`).`, `\`site.basePath\` is \`${basePath || '""'}\`. robots.txt, the`, "sitemap, canonical tags, and llms.txt all derive from these —", "edit `dogsbay.config.yml` and rebuild to change them.", "");
845
+ }
846
+ else {
847
+ lines.push("`site.url` was left **unset** — a migration moves hosts, so the", "source's `site_url` is intentionally not carried over. The build", "emits relative URLs until you set it.", "");
848
+ if (sourceSiteUrl) {
849
+ lines.push(`The source \`mkdocs.yml\` had \`site_url: ${sourceSiteUrl}\` —`, "that points at the *old* host and was dropped on purpose.", "");
850
+ }
851
+ lines.push("Set the destination URL in `dogsbay.config.yml`:", "", "```yaml", "site:", " url: https://you.github.io/your-repo # drives sitemap, llms.txt, canonical", ` basePath: ${basePath || '""'}`, "```", "", "Or re-run the migration with `--site-url` (and optionally", "`--base-path`).", "");
852
+ }
853
+ lines.push("## Re-running the migration", "", "If you find a regression and we ship a fix, re-run with `--force`:", "", "```bash", `npx dogsbay migrate-mkdocs ${sourceDir} --output ${outputDir} --force`, "```", "", "Note that `--force` overwrites all generated files; any hand edits", "to `./content/*.md` since the last migration will be lost. Commit", "your work first.", "");
827
854
  if (lossy.length > 0) {
828
855
  lines.push("## Known limitations", "");
829
856
  lines.push("The following files have content that didn't fully round-trip", "into Dogsbay-MD. Review each one and fix manually:", "");
package/dist/index.js CHANGED
@@ -184,6 +184,13 @@ program
184
184
  .argument("<source>", "Path to MkDocs project (containing mkdocs.yml)")
185
185
  .option("-o, --output <dir>", "Output directory (default: {source}-dogsbay)")
186
186
  .option("--force", "Overwrite an existing Dogsbay site at the output dir")
187
+ .option("--site-url <url>", "Canonical URL of the destination site (e.g. " +
188
+ "https://you.github.io/repo). Drives robots.txt, sitemap, " +
189
+ "canonical tags, and llms.txt. NOT inherited from the source " +
190
+ "mkdocs.yml — a migration moves hosts.")
191
+ .option("--base-path <path>", 'Path under the host where docs are served (default "/docs"). ' +
192
+ 'Pass --base-path "" to serve at the host root — common for a ' +
193
+ "dedicated repo / GitHub Pages project site.")
187
194
  .option("--inline-autodoc", "Resolve mkdocstrings ::: directives at migration time (snapshot). " +
188
195
  "Default is :::autodoc directives that site-build resolves on " +
189
196
  "every build (live re-rendering).")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dogsbay",
3
- "version": "0.2.0-beta.40",
3
+ "version": "0.2.0-beta.42",
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": {
@@ -32,15 +32,15 @@
32
32
  "picocolors": "^1.1.0",
33
33
  "prompts": "^2.4.2",
34
34
  "yaml": "^2.8.3",
35
- "@dogsbay/autodoc-python": "0.2.0-beta.38",
36
- "@dogsbay/format-mkdocs": "0.2.0-beta.40",
37
- "@dogsbay/format-astro": "0.2.0-beta.40",
38
- "@dogsbay/format-obsidian": "0.2.0-beta.40",
39
- "@dogsbay/format-starlight": "0.2.0-beta.40",
40
- "@dogsbay/format-mdx": "0.2.0-beta.40",
41
- "@dogsbay/format-dogsbay-md": "0.2.0-beta.40",
42
- "@dogsbay/types": "0.2.0-beta.40",
43
- "@dogsbay/format-openapi": "0.2.0-beta.40"
35
+ "@dogsbay/autodoc-python": "0.2.0-beta.42",
36
+ "@dogsbay/format-mkdocs": "0.2.0-beta.42",
37
+ "@dogsbay/format-obsidian": "0.2.0-beta.42",
38
+ "@dogsbay/format-astro": "0.2.0-beta.42",
39
+ "@dogsbay/format-mdx": "0.2.0-beta.42",
40
+ "@dogsbay/format-starlight": "0.2.0-beta.42",
41
+ "@dogsbay/format-dogsbay-md": "0.2.0-beta.42",
42
+ "@dogsbay/format-openapi": "0.2.0-beta.42",
43
+ "@dogsbay/types": "0.2.0-beta.42"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/markdown-it": "^14.1.0",
@@ -62,6 +62,39 @@ This was learned the hard way during Phase 3 of
62
62
  emitted `output: "."` and `dogsbay site dev` rebuild-looped on the
63
63
  result. The fix was to revert to the standard `output: "./astro"`.
64
64
 
65
+ ### Destination URL — supplied, not inherited
66
+
67
+ **Do NOT copy the source format's site URL into `site.url`.** A
68
+ migration almost always moves the docs to a *new* host — GitHub
69
+ Pages, a Cloudflare project, a custom domain. The source's
70
+ `site_url` (MkDocs), `url` (Jekyll `_config.yml`), `baseURL`
71
+ (Hugo), etc. points at the *old* host.
72
+
73
+ `site.url` feeds `robots.txt`, the sitemap XML, the `Sitemap:` /
74
+ `Llms-Txt:` lines, canonical tags, `llms.txt` absolute URLs, and
75
+ Astro's `site` / `base`. Inheriting the wrong origin silently
76
+ breaks every one of those — and the breakage only shows up after
77
+ a build, in generated files the user doesn't normally read.
78
+
79
+ **Required:**
80
+ - Migration commands take a `--site-url <url>` flag. Its value
81
+ goes to `dogsbay.config.yml`'s `site.url` *and* the scaffold
82
+ emitter's `siteUrl` option. The URL may carry a path component
83
+ (`https://you.github.io/repo`); `format-astro`'s `parseSiteUrl`
84
+ splits it into Astro `site` (origin) + `base` (urlBase) — this
85
+ is exactly how GitHub Pages **project** sites work.
86
+ - Take a `--base-path <path>` flag too. Default `/docs`; `""`
87
+ serves at the host root. Check `!== undefined` (not truthiness)
88
+ so the empty string is honoured.
89
+ - When `--site-url` is absent, leave `site.url` **unset** (the
90
+ build degrades cleanly to relative URLs) — do NOT fall back to
91
+ the source value.
92
+ - Keep the dropped source URL only to (a) print a one-line note
93
+ after writing the config and (b) record it in `MIGRATION.md`'s
94
+ "Site URL" section so the user knows what to set.
95
+ - The *code* repo URL (`repo_url` etc.) **is** inherited — that
96
+ doesn't change in a docs migration.
97
+
65
98
  ## 2. Asset folder (`content/_assets/`)
66
99
 
67
100
  All images, diagrams, screenshots, icons, PDFs, and downloadable
@@ -247,6 +280,7 @@ Every migration command MUST have a fixture test asserting all of:
247
280
  | `<output>/content/nav.json` does NOT exist | Avoid loader precedence trap |
248
281
  | `<output>/dogsbay.config.yml` has `sources: [{ path: ./content, from: dogsbay-md }]` | Config wires content to source |
249
282
  | `<output>/dogsbay.config.yml` does NOT set `output:` | Use default `./astro` |
283
+ | `site.url` reflects `--site-url`, NOT the source's URL; absent → unset | Destination URL not inherited |
250
284
  | `<output>/astro/package.json` exists | Scaffold under astro/ |
251
285
  | `<output>/astro/astro.config.mjs` exists | Scaffold under astro/ |
252
286
  | `<output>/astro/src/styles/theme.css` exists | Scaffold under astro/ |