@dogsbay/site-files 0.2.0-beta.150 → 0.2.0-beta.151

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.
@@ -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 or an http(s) address throws
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;
@@ -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 === "&" ? "&amp;" : c === "<" ? "&lt;" : c === ">" ? "&gt;" : c === '"' ? "&quot;" : c === "'" ? "&#39;" : 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 or an http(s) address throws
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 (!isSiteLinkHref(link.href))
60
- throw new ProductConfigError(`a link to ${JSON.stringify(link.href)}: a path from the site root (/guide/) or an http(s) address`);
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;
@@ -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.150",
3
+ "version": "0.2.0-beta.151",
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",