@dogsbay/site-files 0.2.0-beta.150 → 0.2.0-beta.152
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/inline-markdown.d.ts +3 -1
- package/dist/inline-markdown.js +10 -4
- package/dist/llms.js +6 -2
- package/dist/site-chrome.js +5 -2
- package/package.json +1 -1
|
@@ -11,8 +11,10 @@ export interface InlineMarkdownOptions {
|
|
|
11
11
|
}
|
|
12
12
|
/** The longest text taken: the chrome's texts are one line. */
|
|
13
13
|
export declare const INLINE_MARKDOWN_MAX = 2000;
|
|
14
|
+
/** A link in the chrome's texts: a site path, an http(s) address or a `mailto:` address. */
|
|
15
|
+
export declare function isTextLinkHref(href: string): boolean;
|
|
14
16
|
/**
|
|
15
|
-
* `text` as inline HTML. A link whose href is not a site path
|
|
17
|
+
* `text` as inline HTML. A link whose href is not a site path, an http(s) or a `mailto:` address throws
|
|
16
18
|
* `ProductConfigError` (the config check: siteChrome renders each text once to find them).
|
|
17
19
|
*/
|
|
18
20
|
export declare function inlineMarkdownHtml(text: string, options?: InlineMarkdownOptions): string;
|
package/dist/inline-markdown.js
CHANGED
|
@@ -9,6 +9,12 @@ import { ProductConfigError } from "./errors.js";
|
|
|
9
9
|
import { isSiteLinkHref } from "./version-menu.js";
|
|
10
10
|
/** The longest text taken: the chrome's texts are one line. */
|
|
11
11
|
export const INLINE_MARKDOWN_MAX = 2000;
|
|
12
|
+
/** A mail address link: `mailto:` and one plain address; no `?subject=`/`bcc=`, `%`-escapes or lists. */
|
|
13
|
+
const MAILTO = /^mailto:[A-Za-z0-9._+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
|
|
14
|
+
/** A link in the chrome's texts: a site path, an http(s) address or a `mailto:` address. */
|
|
15
|
+
export function isTextLinkHref(href) {
|
|
16
|
+
return isSiteLinkHref(href) || MAILTO.test(href);
|
|
17
|
+
}
|
|
12
18
|
/** Emphasis inside emphasis deeper than this is text. */
|
|
13
19
|
const MAX_DEPTH = 8;
|
|
14
20
|
const PUNCT = /[!-/:-@[-`{-~]/;
|
|
@@ -16,7 +22,7 @@ const ENTITY = /^&(?:#\d{1,7}|#[xX][0-9a-fA-F]{1,6}|[A-Za-z][A-Za-z0-9]{1,31});/
|
|
|
16
22
|
const escText = (c) => c === "&" ? "&" : c === "<" ? "<" : c === ">" ? ">" : c === '"' ? """ : c === "'" ? "'" : c;
|
|
17
23
|
const escAll = (s) => s.replace(/[&<>"']/g, escText);
|
|
18
24
|
/**
|
|
19
|
-
* `text` as inline HTML. A link whose href is not a site path
|
|
25
|
+
* `text` as inline HTML. A link whose href is not a site path, an http(s) or a `mailto:` address throws
|
|
20
26
|
* `ProductConfigError` (the config check: siteChrome renders each text once to find them).
|
|
21
27
|
*/
|
|
22
28
|
export function inlineMarkdownHtml(text, options = {}) {
|
|
@@ -56,9 +62,9 @@ function render(s, o, depth, inLink) {
|
|
|
56
62
|
if (c === "[" && !inLink) {
|
|
57
63
|
const link = readLink(s, i);
|
|
58
64
|
if (link) {
|
|
59
|
-
if (!
|
|
60
|
-
throw new ProductConfigError(`a link to ${JSON.stringify(link.href)}: a path from the site root (/guide/)
|
|
61
|
-
const href = o.href ? o.href(link.href) : link.href;
|
|
65
|
+
if (!isTextLinkHref(link.href))
|
|
66
|
+
throw new ProductConfigError(`a link to ${JSON.stringify(link.href)}: a path from the site root (/guide/), an http(s) address or a mailto: address`);
|
|
67
|
+
const href = o.href && !link.href.toLowerCase().startsWith("mailto:") ? o.href(link.href) : link.href;
|
|
62
68
|
out += `<a href="${escAll(href)}">${render(link.label, o, depth, true)}</a>`;
|
|
63
69
|
i = link.end;
|
|
64
70
|
continue;
|
package/dist/llms.js
CHANGED
|
@@ -62,7 +62,7 @@ export function buildLlmsTxt(site, nav, pages, o) {
|
|
|
62
62
|
}
|
|
63
63
|
/** One top-level nav group's own llms.txt. */
|
|
64
64
|
export function buildSectionLlmsTxt(site, group, pages, o) {
|
|
65
|
-
const out = [`# ${site.name} — ${group.label}`, "", `## ${group.label}`, ""];
|
|
65
|
+
const out = [`# ${heading(site.name)} — ${heading(group.label)}`, "", `## ${heading(group.label)}`, ""];
|
|
66
66
|
pushEntry(out, group, pages, o);
|
|
67
67
|
collectEntries(group.children, pages, o, out);
|
|
68
68
|
return finish(out.join("\n"));
|
|
@@ -115,8 +115,12 @@ export function buildLlmsFullTxt(site, order, pages, url, load) {
|
|
|
115
115
|
}
|
|
116
116
|
return parts.join("") + "\n";
|
|
117
117
|
}
|
|
118
|
+
/** A name as one heading line: a line break in it would start lines of its own in the file. */
|
|
119
|
+
function heading(text) {
|
|
120
|
+
return text.replace(/[\r\n\u2028\u2029]+/g, " ").trim();
|
|
121
|
+
}
|
|
118
122
|
function header(site) {
|
|
119
|
-
const out = [`# ${site.name}`, ""];
|
|
123
|
+
const out = [`# ${heading(site.name)}`, ""];
|
|
120
124
|
if (site.description)
|
|
121
125
|
out.push(`> ${site.description}`, "");
|
|
122
126
|
if (site.whenToUse?.trim())
|
package/dist/site-chrome.js
CHANGED
|
@@ -79,9 +79,9 @@ function social(raw, at) {
|
|
|
79
79
|
return { icon: e.icon, href, label: text(e.label, `${where}.label`, false) ?? String(e.icon) };
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
/** Inline Markdown text, its links checked; HTML in it is text (a warning names it). */
|
|
82
|
+
/** Inline Markdown text, its links checked; HTML in it is text (a warning names it). A number (`copyright: 2026`) is its text. */
|
|
83
83
|
function markdown(raw, at, warnings) {
|
|
84
|
-
const t = text(raw, at, false);
|
|
84
|
+
const t = text(typeof raw === "number" && Number.isFinite(raw) ? String(raw) : raw, at, false);
|
|
85
85
|
if (t === undefined)
|
|
86
86
|
return undefined;
|
|
87
87
|
try {
|
|
@@ -180,6 +180,9 @@ export function siteChrome(config) {
|
|
|
180
180
|
headerSocial = social(header.social, "header.social");
|
|
181
181
|
else {
|
|
182
182
|
const repo = typeof site.repoUrl === "string" ? repoSocialLink(site.repoUrl) : undefined;
|
|
183
|
+
if (typeof site.repoUrl === "string" && site.repoUrl.trim() && !repo) {
|
|
184
|
+
warnings.push(`site.repoUrl: ${JSON.stringify(site.repoUrl)} is not an http(s) address, so the header has no repository icon (set header.social)`);
|
|
185
|
+
}
|
|
183
186
|
headerSocial = repo ? [repo] : [];
|
|
184
187
|
}
|
|
185
188
|
const columns = list(footer.columns, "footer.columns").map((e, i) => {
|
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.152",
|
|
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",
|