@dogsbay/site-files 0.2.0-beta.162 → 0.2.0-beta.163
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/mounts.js +3 -1
- package/dist/namespaces.js +3 -1
- package/dist/tree-links.d.ts +11 -0
- package/dist/tree-links.js +12 -2
- package/package.json +1 -1
package/dist/mounts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { rewriteEndpointMarkdown } from "./markdown-links.js";
|
|
2
|
+
import { htmlIsText } from "./tree-links.js";
|
|
2
3
|
/** A mount path's segments, or why it cannot be one. */
|
|
3
4
|
export function parseMount(mount) {
|
|
4
5
|
if (typeof mount !== "string")
|
|
@@ -66,7 +67,8 @@ export function mountRefs(tree, segments, ownSlugs) {
|
|
|
66
67
|
const obj = node;
|
|
67
68
|
if (typeof obj.href === "string")
|
|
68
69
|
obj.href = move(obj.href);
|
|
69
|
-
|
|
70
|
+
// A code block's `html` is its code, shown as written
|
|
71
|
+
if (typeof obj.html === "string" && !htmlIsText(obj)) {
|
|
70
72
|
obj.html = obj.html.replace(/\bhref=("|')(.*?)\1/gi, (_m, q, val) => `href=${q}${move(val)}${q}`);
|
|
71
73
|
}
|
|
72
74
|
// An operation's descriptions are Markdown text, rendered later
|
package/dist/namespaces.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* beside named siblings. A single source, named or not, gets no segment.
|
|
13
13
|
*/
|
|
14
14
|
import { rewriteEndpointMarkdown } from "./markdown-links.js";
|
|
15
|
+
import { htmlIsText } from "./tree-links.js";
|
|
15
16
|
/** A source's namespace: its `name:`, or undefined (flat URLs). */
|
|
16
17
|
export function sourceNamespace(source) {
|
|
17
18
|
return source.name;
|
|
@@ -251,7 +252,8 @@ locales) {
|
|
|
251
252
|
obj.src = prefix(obj.src);
|
|
252
253
|
if (typeof obj.href === "string")
|
|
253
254
|
obj.href = prefix(obj.href);
|
|
254
|
-
|
|
255
|
+
// A code block's `html` is its code: `href=` in it is shown as written (dogsbay-ssg, 2026-11-04)
|
|
256
|
+
if (typeof obj.html === "string" && !htmlIsText(obj))
|
|
255
257
|
obj.html = rewriteHtml(obj.html);
|
|
256
258
|
// An operation's descriptions are Markdown text, rendered later
|
|
257
259
|
// (and its props are the API's data otherwise: an example's `href` is not a link of the site's)
|
package/dist/tree-links.d.ts
CHANGED
|
@@ -3,6 +3,17 @@ export interface TreeLinkFunctions {
|
|
|
3
3
|
link(href: string, inHtml?: boolean): string;
|
|
4
4
|
asset(src: string, inHtml?: boolean): string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Node types whose `html` is text (code, math, a diagram's source), not markup: a code block keeps
|
|
8
|
+
* its code there (format-dogsbay-md), and an `<a href>` in an HTML example is code to show. The same
|
|
9
|
+
* list as @dogsbay/site-check's `SOURCE_TEXT_NODES` (site-files has no dependencies; a CLI test
|
|
10
|
+
* keeps the two equal).
|
|
11
|
+
*/
|
|
12
|
+
export declare const TEXT_HTML_NODES: ReadonlySet<string>;
|
|
13
|
+
/** Is this node's `html` text to show as written (no links to rewrite)? */
|
|
14
|
+
export declare function htmlIsText(node: {
|
|
15
|
+
type?: unknown;
|
|
16
|
+
}): boolean;
|
|
6
17
|
/**
|
|
7
18
|
* Rewrites, in place, the links and file references a page tree carries, where the renderer resolves
|
|
8
19
|
* them (@dogsbay/render-html: `ctx.link`, `ctx.asset`): `href` fields (links, buttons, cards), `src`
|
package/dist/tree-links.js
CHANGED
|
@@ -19,8 +19,18 @@ const MARKDOWN_PROPS = {
|
|
|
19
19
|
table: ["caption"],
|
|
20
20
|
figure: ["caption"],
|
|
21
21
|
};
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Node types whose `html` is text (code, math, a diagram's source), not markup: a code block keeps
|
|
24
|
+
* its code there (format-dogsbay-md), and an `<a href>` in an HTML example is code to show. The same
|
|
25
|
+
* list as @dogsbay/site-check's `SOURCE_TEXT_NODES` (site-files has no dependencies; a CLI test
|
|
26
|
+
* keeps the two equal).
|
|
27
|
+
*/
|
|
28
|
+
export const TEXT_HTML_NODES = new Set(["code", "math", "math-block", "diagram", "mermaid"]);
|
|
29
|
+
const TEXT_HTML = TEXT_HTML_NODES;
|
|
30
|
+
/** Is this node's `html` text to show as written (no links to rewrite)? */
|
|
31
|
+
export function htmlIsText(node) {
|
|
32
|
+
return TEXT_HTML_NODES.has(String(node.type));
|
|
33
|
+
}
|
|
24
34
|
/**
|
|
25
35
|
* Rewrites, in place, the links and file references a page tree carries, where the renderer resolves
|
|
26
36
|
* them (@dogsbay/render-html: `ctx.link`, `ctx.asset`): `href` fields (links, buttons, cards), `src`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dogsbay/site-files",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.163",
|
|
4
4
|
"description": "robots.txt, _headers, llms.txt, sitemaps, redirects and JSON-LD for docs sites; shared by the dogsbay Astro pipeline and dogsbay-ssg, Worker-safe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|