@dogsbay/format-astro 0.2.0-beta.6 → 0.2.0-beta.60
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/base-path.d.ts +105 -7
- package/dist/base-path.d.ts.map +1 -1
- package/dist/base-path.js +136 -7
- package/dist/base-path.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/lead.d.ts +19 -0
- package/dist/lead.d.ts.map +1 -1
- package/dist/lead.js +71 -0
- package/dist/lead.js.map +1 -1
- package/dist/llms-txt.d.ts +13 -2
- package/dist/llms-txt.d.ts.map +1 -1
- package/dist/llms-txt.js +79 -12
- package/dist/llms-txt.js.map +1 -1
- package/dist/project.d.ts +152 -5
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +915 -107
- package/dist/project.js.map +1 -1
- package/dist/serialize.d.ts +22 -0
- package/dist/serialize.d.ts.map +1 -1
- package/dist/serialize.js +159 -17
- package/dist/serialize.js.map +1 -1
- package/dist/sitemap.d.ts +57 -0
- package/dist/sitemap.d.ts.map +1 -0
- package/dist/sitemap.js +136 -0
- package/dist/sitemap.js.map +1 -0
- package/dist/taxonomy.d.ts +37 -0
- package/dist/taxonomy.d.ts.map +1 -1
- package/dist/taxonomy.js +60 -19
- package/dist/taxonomy.js.map +1 -1
- package/package.json +4 -4
package/dist/base-path.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Single source of truth for the `basePath` URL prefix.
|
|
3
3
|
*
|
|
4
|
-
* `basePath` is the path-under-host where docs are served.
|
|
5
|
-
*
|
|
6
|
-
* `site.basePath: ""` in `dogsbay.config.yml`
|
|
7
|
-
*
|
|
4
|
+
* `basePath` is the path-under-host where docs are served. The default
|
|
5
|
+
* is `""` (host root, matching every other SSG); set
|
|
6
|
+
* `site.basePath: "/docs"` in `dogsbay.config.yml` for the legacy
|
|
7
|
+
* "docs nested under marketing site" shape, or `"/handbook"` (etc.)
|
|
8
|
+
* for any other prefix. See plans/default-basepath-root.md for the
|
|
9
|
+
* rationale behind the default flip in v0.3.
|
|
8
10
|
*
|
|
9
11
|
* Every emitter that builds URLs, file paths, or rewrites links
|
|
10
12
|
* reads from `AstroProjectOptions.basePath` and runs it through
|
|
@@ -22,8 +24,18 @@
|
|
|
22
24
|
*
|
|
23
25
|
* See plans/configurable-base-path.md.
|
|
24
26
|
*/
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Default `basePath` when no override is supplied.
|
|
29
|
+
*
|
|
30
|
+
* Changed in v0.3 from `"/docs"` to `""` (host root) so the default
|
|
31
|
+
* matches the plurality of doc-site deployments (GH Pages project
|
|
32
|
+
* sites, `docs.acme.com` subdomains, standalone wikis) and aligns
|
|
33
|
+
* with peer SSGs (Astro, Next, MkDocs, Docusaurus). The `cli`'s
|
|
34
|
+
* `site build` emits a one-shot migration warning when this default
|
|
35
|
+
* is hit so users from the `/docs` era can opt in to either value
|
|
36
|
+
* explicitly. See plans/default-basepath-root.md.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_BASE_PATH = "";
|
|
27
39
|
/**
|
|
28
40
|
* Normalize a user-supplied `basePath` to canonical form.
|
|
29
41
|
*
|
|
@@ -33,7 +45,7 @@ export declare const DEFAULT_BASE_PATH = "/docs";
|
|
|
33
45
|
* non-empty prefix.
|
|
34
46
|
*
|
|
35
47
|
* Examples:
|
|
36
|
-
* - `undefined` → `"/docs"`
|
|
48
|
+
* - `undefined` → `""` (default in v0.3+; was `"/docs"` previously)
|
|
37
49
|
* - `""` → `""`
|
|
38
50
|
* - `"/"` → `""`
|
|
39
51
|
* - `"docs"` → `"/docs"`
|
|
@@ -68,6 +80,92 @@ export declare function basePathSegments(basePath: string): string[];
|
|
|
68
80
|
* - `joinBaseUrl("", undefined, "")` → `"/"`
|
|
69
81
|
*/
|
|
70
82
|
export declare function joinBaseUrl(basePath: string, section: string | undefined, slug: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Prepend the normalized `basePath` onto a raw config-supplied
|
|
85
|
+
* `indexPath` (e.g. `/tags` from `taxonomies.tags.indexPath`),
|
|
86
|
+
* producing the URL prefix that components use to compose hrefs.
|
|
87
|
+
*
|
|
88
|
+
* Different from `joinBaseUrl` because it preserves absolute paths
|
|
89
|
+
* with internal `/` segments and does NOT add a trailing slash —
|
|
90
|
+
* downstream consumers do `${out}/<term>/` themselves.
|
|
91
|
+
*
|
|
92
|
+
* - `withBasePath("/docs", "/tags")` → `"/docs/tags"`
|
|
93
|
+
* - `withBasePath("/docs", "tags")` → `"/docs/tags"`
|
|
94
|
+
* - `withBasePath("", "/tags")` → `"/tags"`
|
|
95
|
+
* - `withBasePath("/docs", "/by-type")` → `"/docs/by-type"`
|
|
96
|
+
*
|
|
97
|
+
* Used for the URL-bearing `indexPath` baked into the taxonomy data
|
|
98
|
+
* file and the `tagsIndexPath` / `taxonomyIndexPaths` Astro props,
|
|
99
|
+
* so components like `<TagList>`, `<TaxonomyIndex>`, `<TaxonomyTerm>`,
|
|
100
|
+
* and `<TypeBadge>` produce hrefs that resolve under the configured
|
|
101
|
+
* site base. Without this prefix, taxonomy navigation 404s on any
|
|
102
|
+
* site with `site.basePath` set.
|
|
103
|
+
*/
|
|
104
|
+
export declare function withBasePath(basePath: string, indexPath: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Parse `site.url` into its origin and path-component parts. The
|
|
107
|
+
* path component (if any) becomes the **urlBase** — the prefix the
|
|
108
|
+
* host serves dist/ at, distinct from `basePath` (which is the
|
|
109
|
+
* filesystem position of content within that served space).
|
|
110
|
+
*
|
|
111
|
+
* Used by emitters that need to (a) emit Astro's `base` config
|
|
112
|
+
* (= urlBase), (b) produce absolute URLs in sitemap / canonical /
|
|
113
|
+
* llms.txt (= origin + combined prefix + slug), or (c) build the
|
|
114
|
+
* combined prefix that internal hrefs need (`combinePrefix` below).
|
|
115
|
+
*
|
|
116
|
+
* Returns `origin` undefined when `siteUrl` is missing or unparseable
|
|
117
|
+
* — the caller then degrades to relative URLs (existing behavior).
|
|
118
|
+
*
|
|
119
|
+
* - `undefined` → `{ origin: undefined, urlBase: "" }`
|
|
120
|
+
* - `"https://example.com"` → `{ origin: "https://example.com", urlBase: "" }`
|
|
121
|
+
* - `"https://example.com/"` → `{ origin: "https://example.com", urlBase: "" }`
|
|
122
|
+
* - `"https://example.com/docs"` → `{ origin: "https://example.com", urlBase: "/docs" }`
|
|
123
|
+
* - `"https://example.com/docs/"` → `{ origin: "https://example.com", urlBase: "/docs" }`
|
|
124
|
+
* - `"https://user.github.io/dogsbay-docs"` → `{ origin: "https://user.github.io", urlBase: "/dogsbay-docs" }`
|
|
125
|
+
* - `"/relative-path"` → `{ origin: undefined, urlBase: "" }` (not a full URL)
|
|
126
|
+
*
|
|
127
|
+
* See plans/astro-base-from-site-url.md.
|
|
128
|
+
*/
|
|
129
|
+
export declare function parseSiteUrl(siteUrl: string | undefined): {
|
|
130
|
+
origin: string | undefined;
|
|
131
|
+
urlBase: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Combine a urlBase (host subpath, from `site.url`) with a
|
|
135
|
+
* basePath (filesystem layout prefix, from `site.basePath`) into the
|
|
136
|
+
* single prefix that nav hrefs, sitemap URLs, llms.txt, and the
|
|
137
|
+
* link rewriter all need.
|
|
138
|
+
*
|
|
139
|
+
* Both inputs MUST already be normalized (output of `normalizeBasePath`
|
|
140
|
+
* or `parseSiteUrl`): empty string OR a single leading slash with no
|
|
141
|
+
* trailing slash. The output respects the same shape.
|
|
142
|
+
*
|
|
143
|
+
* - `combinePrefix("", "")` → `""`
|
|
144
|
+
* - `combinePrefix("", "/docs")` → `"/docs"`
|
|
145
|
+
* - `combinePrefix("/repo", "")` → `"/repo"`
|
|
146
|
+
* - `combinePrefix("/repo", "/docs")` → `"/repo/docs"`
|
|
147
|
+
* - `combinePrefix("/handbook", "/team-docs")` → `"/handbook/team-docs"`
|
|
148
|
+
*
|
|
149
|
+
* See plans/astro-base-from-site-url.md.
|
|
150
|
+
*/
|
|
151
|
+
export declare function combinePrefix(urlBase: string, basePath: string): string;
|
|
152
|
+
/**
|
|
153
|
+
* One-shot resolver: given the user's `site.url` + `site.basePath`,
|
|
154
|
+
* return everything emitters need. Convenience wrapper around
|
|
155
|
+
* `parseSiteUrl` + `normalizeBasePath` + `combinePrefix` so callers
|
|
156
|
+
* only do the math once.
|
|
157
|
+
*
|
|
158
|
+
* Used at the boundary in cli/site-build and cli/site-init to compute
|
|
159
|
+
* the effective prefixes before threading them into the emit tier.
|
|
160
|
+
*
|
|
161
|
+
* See plans/astro-base-from-site-url.md.
|
|
162
|
+
*/
|
|
163
|
+
export declare function resolvePrefixes(siteUrl: string | undefined, basePath: string | undefined): {
|
|
164
|
+
origin: string | undefined;
|
|
165
|
+
urlBase: string;
|
|
166
|
+
basePath: string;
|
|
167
|
+
combined: string;
|
|
168
|
+
};
|
|
71
169
|
/**
|
|
72
170
|
* Build the `currentPath` value embedded in generated `.astro` pages
|
|
73
171
|
* for `getPagination` lookups. No trailing slash so it matches the
|
package/dist/base-path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-path.d.ts","sourceRoot":"","sources":["../src/base-path.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"base-path.d.ts","sourceRoot":"","sources":["../src/base-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKnE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAE3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,GACX,MAAM,CAMR;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG;IACzD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,CAiBA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMvE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B;IACD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CASA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,GACX,MAAM,CAMR"}
|
package/dist/base-path.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Single source of truth for the `basePath` URL prefix.
|
|
3
3
|
*
|
|
4
|
-
* `basePath` is the path-under-host where docs are served.
|
|
5
|
-
*
|
|
6
|
-
* `site.basePath: ""` in `dogsbay.config.yml`
|
|
7
|
-
*
|
|
4
|
+
* `basePath` is the path-under-host where docs are served. The default
|
|
5
|
+
* is `""` (host root, matching every other SSG); set
|
|
6
|
+
* `site.basePath: "/docs"` in `dogsbay.config.yml` for the legacy
|
|
7
|
+
* "docs nested under marketing site" shape, or `"/handbook"` (etc.)
|
|
8
|
+
* for any other prefix. See plans/default-basepath-root.md for the
|
|
9
|
+
* rationale behind the default flip in v0.3.
|
|
8
10
|
*
|
|
9
11
|
* Every emitter that builds URLs, file paths, or rewrites links
|
|
10
12
|
* reads from `AstroProjectOptions.basePath` and runs it through
|
|
@@ -22,8 +24,18 @@
|
|
|
22
24
|
*
|
|
23
25
|
* See plans/configurable-base-path.md.
|
|
24
26
|
*/
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Default `basePath` when no override is supplied.
|
|
29
|
+
*
|
|
30
|
+
* Changed in v0.3 from `"/docs"` to `""` (host root) so the default
|
|
31
|
+
* matches the plurality of doc-site deployments (GH Pages project
|
|
32
|
+
* sites, `docs.acme.com` subdomains, standalone wikis) and aligns
|
|
33
|
+
* with peer SSGs (Astro, Next, MkDocs, Docusaurus). The `cli`'s
|
|
34
|
+
* `site build` emits a one-shot migration warning when this default
|
|
35
|
+
* is hit so users from the `/docs` era can opt in to either value
|
|
36
|
+
* explicitly. See plans/default-basepath-root.md.
|
|
37
|
+
*/
|
|
38
|
+
export const DEFAULT_BASE_PATH = "";
|
|
27
39
|
/**
|
|
28
40
|
* Normalize a user-supplied `basePath` to canonical form.
|
|
29
41
|
*
|
|
@@ -33,7 +45,7 @@ export const DEFAULT_BASE_PATH = "/docs";
|
|
|
33
45
|
* non-empty prefix.
|
|
34
46
|
*
|
|
35
47
|
* Examples:
|
|
36
|
-
* - `undefined` → `"/docs"`
|
|
48
|
+
* - `undefined` → `""` (default in v0.3+; was `"/docs"` previously)
|
|
37
49
|
* - `""` → `""`
|
|
38
50
|
* - `"/"` → `""`
|
|
39
51
|
* - `"docs"` → `"/docs"`
|
|
@@ -86,6 +98,123 @@ export function joinBaseUrl(basePath, section, slug) {
|
|
|
86
98
|
parts.push(slug);
|
|
87
99
|
return parts.length === 0 ? "/" : `/${parts.join("/")}/`;
|
|
88
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Prepend the normalized `basePath` onto a raw config-supplied
|
|
103
|
+
* `indexPath` (e.g. `/tags` from `taxonomies.tags.indexPath`),
|
|
104
|
+
* producing the URL prefix that components use to compose hrefs.
|
|
105
|
+
*
|
|
106
|
+
* Different from `joinBaseUrl` because it preserves absolute paths
|
|
107
|
+
* with internal `/` segments and does NOT add a trailing slash —
|
|
108
|
+
* downstream consumers do `${out}/<term>/` themselves.
|
|
109
|
+
*
|
|
110
|
+
* - `withBasePath("/docs", "/tags")` → `"/docs/tags"`
|
|
111
|
+
* - `withBasePath("/docs", "tags")` → `"/docs/tags"`
|
|
112
|
+
* - `withBasePath("", "/tags")` → `"/tags"`
|
|
113
|
+
* - `withBasePath("/docs", "/by-type")` → `"/docs/by-type"`
|
|
114
|
+
*
|
|
115
|
+
* Used for the URL-bearing `indexPath` baked into the taxonomy data
|
|
116
|
+
* file and the `tagsIndexPath` / `taxonomyIndexPaths` Astro props,
|
|
117
|
+
* so components like `<TagList>`, `<TaxonomyIndex>`, `<TaxonomyTerm>`,
|
|
118
|
+
* and `<TypeBadge>` produce hrefs that resolve under the configured
|
|
119
|
+
* site base. Without this prefix, taxonomy navigation 404s on any
|
|
120
|
+
* site with `site.basePath` set.
|
|
121
|
+
*/
|
|
122
|
+
export function withBasePath(basePath, indexPath) {
|
|
123
|
+
const cleanIndex = indexPath.startsWith("/") ? indexPath : `/${indexPath}`;
|
|
124
|
+
return basePath ? `${basePath}${cleanIndex}` : cleanIndex;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Parse `site.url` into its origin and path-component parts. The
|
|
128
|
+
* path component (if any) becomes the **urlBase** — the prefix the
|
|
129
|
+
* host serves dist/ at, distinct from `basePath` (which is the
|
|
130
|
+
* filesystem position of content within that served space).
|
|
131
|
+
*
|
|
132
|
+
* Used by emitters that need to (a) emit Astro's `base` config
|
|
133
|
+
* (= urlBase), (b) produce absolute URLs in sitemap / canonical /
|
|
134
|
+
* llms.txt (= origin + combined prefix + slug), or (c) build the
|
|
135
|
+
* combined prefix that internal hrefs need (`combinePrefix` below).
|
|
136
|
+
*
|
|
137
|
+
* Returns `origin` undefined when `siteUrl` is missing or unparseable
|
|
138
|
+
* — the caller then degrades to relative URLs (existing behavior).
|
|
139
|
+
*
|
|
140
|
+
* - `undefined` → `{ origin: undefined, urlBase: "" }`
|
|
141
|
+
* - `"https://example.com"` → `{ origin: "https://example.com", urlBase: "" }`
|
|
142
|
+
* - `"https://example.com/"` → `{ origin: "https://example.com", urlBase: "" }`
|
|
143
|
+
* - `"https://example.com/docs"` → `{ origin: "https://example.com", urlBase: "/docs" }`
|
|
144
|
+
* - `"https://example.com/docs/"` → `{ origin: "https://example.com", urlBase: "/docs" }`
|
|
145
|
+
* - `"https://user.github.io/dogsbay-docs"` → `{ origin: "https://user.github.io", urlBase: "/dogsbay-docs" }`
|
|
146
|
+
* - `"/relative-path"` → `{ origin: undefined, urlBase: "" }` (not a full URL)
|
|
147
|
+
*
|
|
148
|
+
* See plans/astro-base-from-site-url.md.
|
|
149
|
+
*/
|
|
150
|
+
export function parseSiteUrl(siteUrl) {
|
|
151
|
+
if (!siteUrl)
|
|
152
|
+
return { origin: undefined, urlBase: "" };
|
|
153
|
+
// Only accept absolute http(s) URLs as full site URLs. Anything else
|
|
154
|
+
// (relative paths, mailto:, tel:, …) yields no origin — emitters
|
|
155
|
+
// fall back to whatever they do today when site.url is missing.
|
|
156
|
+
if (!/^https?:\/\//i.test(siteUrl)) {
|
|
157
|
+
return { origin: undefined, urlBase: "" };
|
|
158
|
+
}
|
|
159
|
+
let parsed;
|
|
160
|
+
try {
|
|
161
|
+
parsed = new URL(siteUrl);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return { origin: undefined, urlBase: "" };
|
|
165
|
+
}
|
|
166
|
+
const origin = `${parsed.protocol}//${parsed.host}`;
|
|
167
|
+
const urlBase = normalizeBasePath(parsed.pathname);
|
|
168
|
+
return { origin, urlBase };
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Combine a urlBase (host subpath, from `site.url`) with a
|
|
172
|
+
* basePath (filesystem layout prefix, from `site.basePath`) into the
|
|
173
|
+
* single prefix that nav hrefs, sitemap URLs, llms.txt, and the
|
|
174
|
+
* link rewriter all need.
|
|
175
|
+
*
|
|
176
|
+
* Both inputs MUST already be normalized (output of `normalizeBasePath`
|
|
177
|
+
* or `parseSiteUrl`): empty string OR a single leading slash with no
|
|
178
|
+
* trailing slash. The output respects the same shape.
|
|
179
|
+
*
|
|
180
|
+
* - `combinePrefix("", "")` → `""`
|
|
181
|
+
* - `combinePrefix("", "/docs")` → `"/docs"`
|
|
182
|
+
* - `combinePrefix("/repo", "")` → `"/repo"`
|
|
183
|
+
* - `combinePrefix("/repo", "/docs")` → `"/repo/docs"`
|
|
184
|
+
* - `combinePrefix("/handbook", "/team-docs")` → `"/handbook/team-docs"`
|
|
185
|
+
*
|
|
186
|
+
* See plans/astro-base-from-site-url.md.
|
|
187
|
+
*/
|
|
188
|
+
export function combinePrefix(urlBase, basePath) {
|
|
189
|
+
// Both already normalized — concatenation is safe; no double slashes
|
|
190
|
+
// appear because each is empty OR starts with `/` and has no trailing.
|
|
191
|
+
if (!urlBase)
|
|
192
|
+
return basePath;
|
|
193
|
+
if (!basePath)
|
|
194
|
+
return urlBase;
|
|
195
|
+
return `${urlBase}${basePath}`;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* One-shot resolver: given the user's `site.url` + `site.basePath`,
|
|
199
|
+
* return everything emitters need. Convenience wrapper around
|
|
200
|
+
* `parseSiteUrl` + `normalizeBasePath` + `combinePrefix` so callers
|
|
201
|
+
* only do the math once.
|
|
202
|
+
*
|
|
203
|
+
* Used at the boundary in cli/site-build and cli/site-init to compute
|
|
204
|
+
* the effective prefixes before threading them into the emit tier.
|
|
205
|
+
*
|
|
206
|
+
* See plans/astro-base-from-site-url.md.
|
|
207
|
+
*/
|
|
208
|
+
export function resolvePrefixes(siteUrl, basePath) {
|
|
209
|
+
const { origin, urlBase } = parseSiteUrl(siteUrl);
|
|
210
|
+
const normalizedBasePath = normalizeBasePath(basePath);
|
|
211
|
+
return {
|
|
212
|
+
origin,
|
|
213
|
+
urlBase,
|
|
214
|
+
basePath: normalizedBasePath,
|
|
215
|
+
combined: combinePrefix(urlBase, normalizedBasePath),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
89
218
|
/**
|
|
90
219
|
* Build the `currentPath` value embedded in generated `.astro` pages
|
|
91
220
|
* for `getPagination` lookups. No trailing slash so it matches the
|
package/dist/base-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-path.js","sourceRoot":"","sources":["../src/base-path.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"base-path.js","sourceRoot":"","sources":["../src/base-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IACzD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,iBAAiB,CAAC;IAClD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC9D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,OAAO,IAAI,OAAO,EAAE,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAA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gBAAgB,CAC9B,QAAgB,EAChB,OAA2B,EAC3B,IAAY;IAEZ,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9D,IAAI,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { treeToAstro, escapeExpr, escapeAttr, escapeTemplate } from "./serialize.js";
|
|
2
|
-
export { detectLeadingNodes } from "./lead.js";
|
|
2
|
+
export { detectLeadingNodes, deriveDescription } from "./lead.js";
|
|
3
3
|
export type { LeadingNodeInfo } from "./lead.js";
|
|
4
4
|
export type { AstroGenResult, AstroGenOptions, AstroRenderMode } from "./serialize.js";
|
|
5
|
-
export { DEFAULT_BASE_PATH, normalizeBasePath, basePathSegments, joinBaseUrl, buildCurrentPath, } from "./base-path.js";
|
|
5
|
+
export { DEFAULT_BASE_PATH, normalizeBasePath, basePathSegments, joinBaseUrl, buildCurrentPath, parseSiteUrl, combinePrefix, resolvePrefixes, } from "./base-path.js";
|
|
6
6
|
export { buildLlmsTxt, buildSectionLlmsTxt, buildLlmsFullTxt, extractFirstParagraph, } from "./llms-txt.js";
|
|
7
7
|
export type { BuildLlmsTxtOptions, BuildLlmsFullTxtOptions, } from "./llms-txt.js";
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
8
|
+
export { buildSitemap, buildSitemapIndex } from "./sitemap.js";
|
|
9
|
+
export type { BuildSitemapOptions } from "./sitemap.js";
|
|
10
|
+
export { exportAstroProject, emitSiteScaffold, emitSiteConfig, emitAstroPages, emitConfigDerivedFiles, emitAgentReadinessFiles, emitSwitcherMap, emitMissingTranslationStubs, emitPassthroughAstroPages, emitDeployArtifacts, } from "./project.js";
|
|
11
|
+
export type { AstroProjectOptions, SwitcherMap, PassthroughCopy, } from "./project.js";
|
|
10
12
|
export { emitPluginRuntime } from "./plugins.js";
|
|
11
13
|
export type { EmitPluginRuntimeOptions, PluginClientModulesGroup, PluginStylesGroup, PluginClientConfig, } from "./plugins.js";
|
|
12
14
|
export { buildTaxonomyData, emitTaxonomyForName, emitTaxonomyRoutes, getPageTerms, } from "./taxonomy.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMrF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKvF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAaxD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,2BAA2B,EAC3B,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,eAAe,GAChB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,15 @@ export { treeToAstro, escapeExpr, escapeAttr, escapeTemplate } from "./serialize
|
|
|
4
4
|
// has a leading H1 / paragraph so format-astro can decide whether
|
|
5
5
|
// to inject frontmatter title + description at the top of <main>.
|
|
6
6
|
// See plans/auto-lede.md.
|
|
7
|
-
export { detectLeadingNodes } from "./lead.js";
|
|
7
|
+
export { detectLeadingNodes, deriveDescription } from "./lead.js";
|
|
8
8
|
// Base-path helpers — single source of truth for the `basePath` URL
|
|
9
9
|
// prefix shared across project / nav / llms-txt / taxonomy emitters.
|
|
10
10
|
// See plans/configurable-base-path.md.
|
|
11
|
-
export { DEFAULT_BASE_PATH, normalizeBasePath, basePathSegments, joinBaseUrl, buildCurrentPath, } from "./base-path.js";
|
|
11
|
+
export { DEFAULT_BASE_PATH, normalizeBasePath, basePathSegments, joinBaseUrl, buildCurrentPath, parseSiteUrl, combinePrefix, resolvePrefixes, } from "./base-path.js";
|
|
12
12
|
// llms.txt + llms-full.txt builders (LLM discovery files)
|
|
13
13
|
export { buildLlmsTxt, buildSectionLlmsTxt, buildLlmsFullTxt, extractFirstParagraph, } from "./llms-txt.js";
|
|
14
|
+
// Sitemap builders (per-mount, sitemaps.org 0.9)
|
|
15
|
+
export { buildSitemap, buildSitemapIndex } from "./sitemap.js";
|
|
14
16
|
// Project export — orchestrator + per-tier emitters
|
|
15
17
|
//
|
|
16
18
|
// `exportAstroProject` is the high-level entry: generates a complete
|
|
@@ -22,7 +24,7 @@ export { buildLlmsTxt, buildSectionLlmsTxt, buildLlmsFullTxt, extractFirstParagr
|
|
|
22
24
|
// alone; `dogsbay site build` calls `emitAstroPages` +
|
|
23
25
|
// `emitConfigDerivedFiles` + `emitAgentReadinessFiles`. Pure
|
|
24
26
|
// `dogsbay convert --to astro` (Step 7) calls only `emitAstroPages`.
|
|
25
|
-
export { exportAstroProject, emitSiteScaffold, emitSiteConfig, emitAstroPages, emitConfigDerivedFiles, emitAgentReadinessFiles, emitSwitcherMap, emitMissingTranslationStubs, } from "./project.js";
|
|
27
|
+
export { exportAstroProject, emitSiteScaffold, emitSiteConfig, emitAstroPages, emitConfigDerivedFiles, emitAgentReadinessFiles, emitSwitcherMap, emitMissingTranslationStubs, emitPassthroughAstroPages, emitDeployArtifacts, } from "./project.js";
|
|
26
28
|
// Plugin runtime codegen — emits the entry, virtual config modules,
|
|
27
29
|
// stylesheets, and Vite alias file each plugin needs to participate
|
|
28
30
|
// in the Astro / Vite build. See plans/plugin-api.md.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD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AO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQjD,kEAAkE;AAClE,uEAAuE;AACvE,0DAA0D;AAC1D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,GACb,MAAM,eAAe,CAAC"}
|
package/dist/lead.d.ts
CHANGED
|
@@ -36,4 +36,23 @@ export interface LeadingNodeInfo {
|
|
|
36
36
|
* `false` for both flags when the tree is empty.
|
|
37
37
|
*/
|
|
38
38
|
export declare function detectLeadingNodes(tree: TreeNode[] | undefined): LeadingNodeInfo;
|
|
39
|
+
/**
|
|
40
|
+
* Derive a `<meta name="description">` from a page body when the
|
|
41
|
+
* frontmatter doesn't supply one: the first prose paragraph,
|
|
42
|
+
* whitespace-collapsed and truncated at a word boundary.
|
|
43
|
+
*
|
|
44
|
+
* Deliberately Minja-unaware. This only runs at build time, on the
|
|
45
|
+
* preprocessed (resolved) tree — `{{ var }}` and `{% include %}` are
|
|
46
|
+
* already gone, so the first paragraph is real prose. (A still-undefined
|
|
47
|
+
* `{{ var }}` survives `preserve` mode, but that's a content bug equally
|
|
48
|
+
* visible in the body and already flagged by the `unresolved-directives`
|
|
49
|
+
* audit — not the description's job to scrub.) The `--no-preprocess` /
|
|
50
|
+
* `dogsbay convert` paths emit unresolved output by design, where a
|
|
51
|
+
* slightly-off description is the least of it.
|
|
52
|
+
*
|
|
53
|
+
* Scans past a leading H1 / heading / code to the first prose paragraph;
|
|
54
|
+
* returns `undefined` when the page has no prose. See
|
|
55
|
+
* plans/auto-meta-description.md.
|
|
56
|
+
*/
|
|
57
|
+
export declare function deriveDescription(tree: TreeNode[] | undefined, maxLen?: number): string | undefined;
|
|
39
58
|
//# sourceMappingURL=lead.d.ts.map
|
package/dist/lead.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lead.d.ts","sourceRoot":"","sources":["../src/lead.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;;;;;;;OASG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,GAC3B,eAAe,CAcjB"}
|
|
1
|
+
{"version":3,"file":"lead.d.ts","sourceRoot":"","sources":["../src/lead.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;;;;;;;OASG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,GAC3B,eAAe,CAcjB;AAmBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,EAC5B,MAAM,SAAM,GACX,MAAM,GAAG,SAAS,CAYpB"}
|
package/dist/lead.js
CHANGED
|
@@ -35,4 +35,75 @@ function isParagraph(node) {
|
|
|
35
35
|
return false;
|
|
36
36
|
return node.type === "paragraph";
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Derive a `<meta name="description">` from a page body when the
|
|
40
|
+
* frontmatter doesn't supply one: the first prose paragraph,
|
|
41
|
+
* whitespace-collapsed and truncated at a word boundary.
|
|
42
|
+
*
|
|
43
|
+
* Deliberately Minja-unaware. This only runs at build time, on the
|
|
44
|
+
* preprocessed (resolved) tree — `{{ var }}` and `{% include %}` are
|
|
45
|
+
* already gone, so the first paragraph is real prose. (A still-undefined
|
|
46
|
+
* `{{ var }}` survives `preserve` mode, but that's a content bug equally
|
|
47
|
+
* visible in the body and already flagged by the `unresolved-directives`
|
|
48
|
+
* audit — not the description's job to scrub.) The `--no-preprocess` /
|
|
49
|
+
* `dogsbay convert` paths emit unresolved output by design, where a
|
|
50
|
+
* slightly-off description is the least of it.
|
|
51
|
+
*
|
|
52
|
+
* Scans past a leading H1 / heading / code to the first prose paragraph;
|
|
53
|
+
* returns `undefined` when the page has no prose. See
|
|
54
|
+
* plans/auto-meta-description.md.
|
|
55
|
+
*/
|
|
56
|
+
export function deriveDescription(tree, maxLen = 155) {
|
|
57
|
+
if (!tree || tree.length === 0)
|
|
58
|
+
return undefined;
|
|
59
|
+
// Skip a leading H1 (the page title) so the lede is the node after it.
|
|
60
|
+
let i = isH1(tree[0]) ? 1 : 0;
|
|
61
|
+
for (; i < tree.length; i++) {
|
|
62
|
+
const node = tree[i];
|
|
63
|
+
if (node.type !== "paragraph")
|
|
64
|
+
continue; // skip headings/code/etc.
|
|
65
|
+
const text = paragraphText(node).replace(/\s+/g, " ").trim();
|
|
66
|
+
if (!text)
|
|
67
|
+
continue;
|
|
68
|
+
return truncateAtWord(text, maxLen);
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Flatten a paragraph node's text. Tolerant of the three shapes
|
|
74
|
+
* format-astro already handles: flat `node.inline`, wrapped
|
|
75
|
+
* `node.children[{ inline }]`, and pre-rendered `node.html`.
|
|
76
|
+
*/
|
|
77
|
+
function paragraphText(node) {
|
|
78
|
+
const parts = [];
|
|
79
|
+
const visit = (n) => {
|
|
80
|
+
if (!n || typeof n !== "object")
|
|
81
|
+
return;
|
|
82
|
+
const o = n;
|
|
83
|
+
if (typeof o.text === "string")
|
|
84
|
+
parts.push(o.text);
|
|
85
|
+
if (typeof o.code === "string")
|
|
86
|
+
parts.push(o.code);
|
|
87
|
+
if (Array.isArray(o.inline))
|
|
88
|
+
o.inline.forEach(visit);
|
|
89
|
+
if (Array.isArray(o.children))
|
|
90
|
+
o.children.forEach(visit);
|
|
91
|
+
};
|
|
92
|
+
if (Array.isArray(node.inline))
|
|
93
|
+
node.inline.forEach(visit);
|
|
94
|
+
else if (Array.isArray(node.children))
|
|
95
|
+
node.children.forEach(visit);
|
|
96
|
+
else if (typeof node.html === "string") {
|
|
97
|
+
parts.push(node.html.replace(/<[^>]+>/g, ""));
|
|
98
|
+
}
|
|
99
|
+
return parts.join("");
|
|
100
|
+
}
|
|
101
|
+
function truncateAtWord(s, max) {
|
|
102
|
+
if (s.length <= max)
|
|
103
|
+
return s;
|
|
104
|
+
const cut = s.slice(0, max);
|
|
105
|
+
const lastSpace = cut.lastIndexOf(" ");
|
|
106
|
+
const base = lastSpace > max * 0.6 ? cut.slice(0, lastSpace) : cut;
|
|
107
|
+
return base.replace(/[\s.,;:!?-]+$/, "") + "…";
|
|
108
|
+
}
|
|
38
109
|
//# sourceMappingURL=lead.js.map
|
package/dist/lead.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lead.js","sourceRoot":"","sources":["../src/lead.ts"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAA4B;IAE5B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAE9B,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,KAAK,EAA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C,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,cAAc,CAAC,CAAS,EAAE,GAAW;IAC5C,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,SAAS,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACnE,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;AACjD,CAAC"}
|
package/dist/llms-txt.d.ts
CHANGED
|
@@ -35,6 +35,14 @@ export interface BuildLlmsTxtOptions {
|
|
|
35
35
|
* Default: "Documentation".
|
|
36
36
|
*/
|
|
37
37
|
topLevelLabel?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Label for pages that exist in `pages` but are not reachable via
|
|
40
|
+
* `nav`. They're appended under a final section so agents see the
|
|
41
|
+
* full content surface even when nav curates a subset for human
|
|
42
|
+
* sidebars. Default: "Other pages". Set to `false` to suppress
|
|
43
|
+
* orphan emission entirely (matches pre-decoupling behavior).
|
|
44
|
+
*/
|
|
45
|
+
otherPagesLabel?: string | false;
|
|
38
46
|
}
|
|
39
47
|
export interface BuildLlmsFullTxtOptions extends BuildLlmsTxtOptions {
|
|
40
48
|
/**
|
|
@@ -56,8 +64,11 @@ export interface BuildLlmsFullTxtOptions extends BuildLlmsTxtOptions {
|
|
|
56
64
|
* Layout:
|
|
57
65
|
* - One `## {label}` section per top-level nav group with children.
|
|
58
66
|
* - Top-level leaf nav items collected into a single
|
|
59
|
-
* `## {topLevelLabel}` block
|
|
60
|
-
* -
|
|
67
|
+
* `## {topLevelLabel}` block.
|
|
68
|
+
* - Pages reachable in `pages` but absent from `nav` appended under
|
|
69
|
+
* a final `## {otherPagesLabel}` section. Set `otherPagesLabel`
|
|
70
|
+
* to `false` to suppress (e.g. when nav is the publish list).
|
|
71
|
+
* - External hrefs are skipped.
|
|
61
72
|
*/
|
|
62
73
|
export declare function buildLlmsTxt(siteConfig: Pick<SiteConfig, "siteName" | "description" | "siteUrl">, nav: NavItem[], pages: ExportPage[], options?: BuildLlmsTxtOptions): string;
|
|
63
74
|
/**
|
package/dist/llms-txt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llms-txt.d.ts","sourceRoot":"","sources":["../src/llms-txt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EACV,UAAU,EAEV,OAAO,EACP,UAAU,EACV,QAAQ,EACT,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"llms-txt.d.ts","sourceRoot":"","sources":["../src/llms-txt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EACV,UAAU,EAEV,OAAO,EACP,UAAU,EACV,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAWxB,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,G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