@dogsbay/format-astro 0.2.0-beta.145 → 0.2.0-beta.146
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/project.d.ts +10 -0
- package/dist/project.js +33 -3
- package/package.json +7 -7
package/dist/project.d.ts
CHANGED
|
@@ -206,6 +206,16 @@ export interface AstroProjectOptions {
|
|
|
206
206
|
* `_dogsbay/versions.js` and `<unit home>_dogsbay/pages.js`.
|
|
207
207
|
*/
|
|
208
208
|
products?: ProductModel;
|
|
209
|
+
/**
|
|
210
|
+
* The project's own `_headers` / `_redirects` (from the root of a source served at the site
|
|
211
|
+
* root): written first, the generated rules after, generated ones they already decide left out
|
|
212
|
+
* (@dogsbay/site-files host-files.ts, as dogsbay-ssg does). With its own `_redirects` the file is
|
|
213
|
+
* written whatever `deploy` says, since the project's host reads it.
|
|
214
|
+
*/
|
|
215
|
+
hostFiles?: {
|
|
216
|
+
headers?: string;
|
|
217
|
+
redirects?: string;
|
|
218
|
+
};
|
|
209
219
|
/**
|
|
210
220
|
* Declared locales for the i18n axis. Same role as
|
|
211
221
|
* `versions` for the locale axis.
|
package/dist/project.js
CHANGED
|
@@ -30,7 +30,7 @@ import { buildSitemapFiles, buildSitemapIndex } from "./sitemap.js";
|
|
|
30
30
|
import { canonicalPlan } from "./canonical.js";
|
|
31
31
|
import { headMetadata } from "./head-metadata.js";
|
|
32
32
|
import { buildHeadersFile, buildRobotsTxt as buildRobotsTxtFile } from "@dogsbay/site-files";
|
|
33
|
-
import { productRootRedirects, siteFiles, siteRootTarget, switcher as productSwitcherRows, toPagesScript, toScript, unitKeyString, unitManifest, unitOf, } from "@dogsbay/site-files";
|
|
33
|
+
import { mergeHeaders, mergeRedirects, productRootRedirects, siteFiles, siteRootTarget, switcher as productSwitcherRows, toPagesScript, toScript, unitKeyString, unitManifest, unitOf, } from "@dogsbay/site-files";
|
|
34
34
|
import { assembleBook, estimateTreeBytes } from "./granularity.js";
|
|
35
35
|
/**
|
|
36
36
|
* The per-topic "Read as single page" affordance (granularity book view).
|
|
@@ -2473,9 +2473,21 @@ function emitRedirects(outputDir, options, pages) {
|
|
|
2473
2473
|
}
|
|
2474
2474
|
for (const w of warnings)
|
|
2475
2475
|
console.warn(` Warning: ${w}`);
|
|
2476
|
+
const publicDir = join(outputDir, "public");
|
|
2477
|
+
const own = options.hostFiles?.redirects;
|
|
2478
|
+
if (own !== undefined) {
|
|
2479
|
+
// The project's _redirects first, ours after: written whatever the deploy target, since their host reads it
|
|
2480
|
+
const merged = mergeRedirects(own, rules.length ? renderRedirectsFile(rules) : undefined, options.deploy === "cloudflare-workers");
|
|
2481
|
+
mkdirSync(publicDir, { recursive: true });
|
|
2482
|
+
writeFileSync(join(publicDir, "_redirects"), merged.text);
|
|
2483
|
+
for (const n of merged.notes)
|
|
2484
|
+
console.warn(` Warning: ${n}`);
|
|
2485
|
+
console.log(` Redirects: the project's _redirects, then the generated rules it does not already decide → public/_redirects`);
|
|
2486
|
+
if (options.deploy === "cloudflare-workers")
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2476
2489
|
if (rules.length === 0)
|
|
2477
2490
|
return;
|
|
2478
|
-
const publicDir = join(outputDir, "public");
|
|
2479
2491
|
if (options.deploy === "cloudflare-workers") {
|
|
2480
2492
|
// Workers Static Assets reads _redirects from the ROOT of the assets
|
|
2481
2493
|
// directory. On a subpath mount `public/` lands at dist/<mount>/, so the
|
|
@@ -2816,6 +2828,15 @@ function buildMissingTranslationStub(defaultUrl, fromLocale, toLocale) {
|
|
|
2816
2828
|
* `emitAstroPages` (they share the page-loop's serialization step).
|
|
2817
2829
|
*/
|
|
2818
2830
|
export function emitAgentReadinessFiles(pages, outputNav, outputDir, siteName, options) {
|
|
2831
|
+
// The project's own _headers first, the generated Link header after (when llms.txt is on)
|
|
2832
|
+
const ownHeaders = options.hostFiles?.headers;
|
|
2833
|
+
if (ownHeaders !== undefined && options.llmsTxt === false) {
|
|
2834
|
+
mkdirSync(join(outputDir, "public"), { recursive: true });
|
|
2835
|
+
const merged = mergeHeaders(ownHeaders, undefined, options.deploy === "cloudflare-workers");
|
|
2836
|
+
writeFileSync(join(outputDir, "public", "_headers"), merged.text);
|
|
2837
|
+
for (const n of merged.notes)
|
|
2838
|
+
console.warn(` Warning: ${n}`);
|
|
2839
|
+
}
|
|
2819
2840
|
if (options.llmsTxt !== false) {
|
|
2820
2841
|
emitLlmsTxtFiles(outputDir, siteName, options, outputNav, pages);
|
|
2821
2842
|
// public/_headers — Cloudflare Workers / Pages convention. Adds an
|
|
@@ -2825,7 +2846,16 @@ export function emitAgentReadinessFiles(pages, outputNav, outputDir, siteName, o
|
|
|
2825
2846
|
mkdirSync(join(outputDir, "public"), { recursive: true });
|
|
2826
2847
|
// _headers Link header points at the per-mount llms.txt at
|
|
2827
2848
|
// <combined>/llms.txt — the URL agents would actually fetch.
|
|
2828
|
-
|
|
2849
|
+
const generated = buildHeadersFile(withBasePath(combinedPrefix(options), "/llms.txt"));
|
|
2850
|
+
if (ownHeaders === undefined) {
|
|
2851
|
+
writeFileSync(join(outputDir, "public", "_headers"), generated);
|
|
2852
|
+
}
|
|
2853
|
+
else {
|
|
2854
|
+
const merged = mergeHeaders(ownHeaders, generated, options.deploy === "cloudflare-workers");
|
|
2855
|
+
writeFileSync(join(outputDir, "public", "_headers"), merged.text);
|
|
2856
|
+
for (const n of merged.notes)
|
|
2857
|
+
console.warn(` Warning: ${n}`);
|
|
2858
|
+
}
|
|
2829
2859
|
}
|
|
2830
2860
|
// Sitemap — emitted by Dogsbay (not @astrojs/sitemap) into
|
|
2831
2861
|
// public/<basePath>/sitemap-{index,0}.xml so multi-mount deploys
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dogsbay/format-astro",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.146",
|
|
4
4
|
"description": "Astro format plugin for Dogsbay — export TreeNode[] to Astro component markup",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"markdown-it": "^14.3.0",
|
|
35
|
-
"@dogsbay/format-dogsbay-md": "0.2.0-beta.
|
|
36
|
-
"@dogsbay/
|
|
37
|
-
"@dogsbay/
|
|
38
|
-
"@dogsbay/site-files": "0.2.0-beta.
|
|
39
|
-
"@dogsbay/
|
|
40
|
-
"@dogsbay/
|
|
35
|
+
"@dogsbay/format-dogsbay-md": "0.2.0-beta.146",
|
|
36
|
+
"@dogsbay/render-html": "0.2.0-beta.146",
|
|
37
|
+
"@dogsbay/serialize-core": "0.2.0-beta.146",
|
|
38
|
+
"@dogsbay/site-files": "0.2.0-beta.146",
|
|
39
|
+
"@dogsbay/types": "0.2.0-beta.146",
|
|
40
|
+
"@dogsbay/ui": "0.2.0-beta.146"
|
|
41
41
|
},
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|