@sarimarcus/content-sites-core 0.25.0 → 0.26.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All packages in the platform release in lockstep; entries are per release version.
4
4
 
5
+ ## 0.26.0 (2026-10-05)
6
+
7
+ - `./url`: `publicImageUrl(image, basePath = '/')` — a `public/` asset path under the base path; absolute, protocol-relative and relative values pass through, no image stays undefined. It replaces the copies in the sites' affiliate utils (SLA-2921).
8
+
5
9
  ## 0.25.0 (2026-10-05)
6
10
 
7
11
  - No changes; lockstep release with ui and tourism (SLA-2961).
@@ -1,4 +1,4 @@
1
- export { url, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from './url.ts';
1
+ export { url, publicImageUrl, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from './url.ts';
2
2
  export { getOgImagePath } from './ogImage.ts';
3
3
  export { normalizeHref, extractProseHrefs, dedupRelated } from './relatedDedup.ts';
4
4
  export { buildImageMap, keyBySlug } from './imageMap.ts';
package/dist/url/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Public surface of @sarimarcus/content-sites-core/url.
2
- export { url, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from "./url.js";
2
+ export { url, publicImageUrl, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from "./url.js";
3
3
  export { getOgImagePath } from "./ogImage.js";
4
4
  export { normalizeHref, extractProseHrefs, dedupRelated } from "./relatedDedup.js";
5
5
  export { buildImageMap, keyBySlug } from "./imageMap.js";
package/dist/url/url.d.ts CHANGED
@@ -3,3 +3,10 @@ export declare function url(path: string, basePath?: string): string;
3
3
  export declare function normalizePagePath(pathname: string, basePath?: string): string;
4
4
  export declare function toAbsoluteSiteUrl(pathname: string, siteUrl: string, basePath?: string): string;
5
5
  export declare function normalizeSiteUrl(input: string, siteUrl: string, basePath?: string): string;
6
+ /**
7
+ * A `public/` asset path under the site base path, for an image a data file names: a root-relative path gets the
8
+ * base; an absolute or protocol-relative URL and a relative path pass through; no image stays undefined. Unlike
9
+ * `url()`, it never rewrites a URL that is not root-relative.
10
+ */
11
+ export declare function publicImageUrl(image: string, basePath?: string): string;
12
+ export declare function publicImageUrl(image?: string, basePath?: string): string | undefined;
package/dist/url/url.js CHANGED
@@ -57,3 +57,9 @@ export function normalizeSiteUrl(input, siteUrl, basePath = '/') {
57
57
  return input;
58
58
  }
59
59
  }
60
+ export function publicImageUrl(image, basePath = '/') {
61
+ if (!image)
62
+ return undefined;
63
+ const cleanBase = basePath.replace(/\/$/, '');
64
+ return image.startsWith('/') && !image.startsWith('//') ? `${cleanBase}${image}` : image;
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-core",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Non-visual utilities, Astro config builders and SEO schema assembly shared by the content sites.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/url/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Public surface of @sarimarcus/content-sites-core/url.
2
- export { url, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from './url.ts';
2
+ export { url, publicImageUrl, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from './url.ts';
3
3
  export { getOgImagePath } from './ogImage.ts';
4
4
  export { normalizeHref, extractProseHrefs, dedupRelated } from './relatedDedup.ts';
5
5
  export { buildImageMap, keyBySlug } from './imageMap.ts';
package/src/url/url.ts CHANGED
@@ -72,3 +72,16 @@ export function normalizeSiteUrl(input: string, siteUrl: string, basePath = '/')
72
72
  return input;
73
73
  }
74
74
  }
75
+
76
+ /**
77
+ * A `public/` asset path under the site base path, for an image a data file names: a root-relative path gets the
78
+ * base; an absolute or protocol-relative URL and a relative path pass through; no image stays undefined. Unlike
79
+ * `url()`, it never rewrites a URL that is not root-relative.
80
+ */
81
+ export function publicImageUrl(image: string, basePath?: string): string;
82
+ export function publicImageUrl(image?: string, basePath?: string): string | undefined;
83
+ export function publicImageUrl(image?: string, basePath = '/'): string | undefined {
84
+ if (!image) return undefined;
85
+ const cleanBase = basePath.replace(/\/$/, '');
86
+ return image.startsWith('/') && !image.startsWith('//') ? `${cleanBase}${image}` : image;
87
+ }