brease-client 0.7.0 → 0.7.1

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/README.md CHANGED
@@ -107,6 +107,21 @@ export default {
107
107
  }
108
108
  ```
109
109
 
110
+ ### Structured data (JSON-LD)
111
+
112
+ `toMetadata` can't output scripts, so render the page's structured data with `jsonLd` (framework-free, from the
113
+ root export). Each item's `json` is escaped for use inside a script tag.
114
+
115
+ ```tsx
116
+ import { jsonLd } from 'brease-client'
117
+
118
+ {jsonLd(page.resolvedSeo).map((item, i) => (
119
+ <script key={i} type="application/ld+json" dangerouslySetInnerHTML={{ __html: item.json }} />
120
+ ))}
121
+ ```
122
+
123
+ `headTags` (HTML) and `breaseHead` (Astro) already include it; `jsonLdHtml(seo)` gives only the scripts.
124
+
110
125
  ### Google Analytics (GA4)
111
126
 
112
127
  When GA4 is linked in Brease (Connections → Google) with "Add the tag to the site" on, the site response carries
package/dist/astro.cjs CHANGED
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ // src/structured-data.ts
4
+ var jsonLdText = (data) => JSON.stringify(data).replace(/</g, "\\u003c");
5
+ function jsonLd(seo) {
6
+ return (seo.structuredData ?? []).map((data) => ({ data, json: jsonLdText(data) }));
7
+ }
8
+
3
9
  // src/html.ts
4
10
  function headTagList(seo, opts = {}) {
5
11
  const tags = [{ tag: "title", attrs: {}, content: seo.title }];
@@ -34,12 +40,8 @@ function headTagList(seo, opts = {}) {
34
40
  meta("name", "twitter:description", tw.description);
35
41
  meta("name", "twitter:image", tw.image);
36
42
  if (seo.favicon) tags.push({ tag: "link", attrs: { rel: "icon", href: seo.favicon } });
37
- for (const data of seo.structuredData) {
38
- tags.push({
39
- tag: "script",
40
- attrs: { type: "application/ld+json" },
41
- content: JSON.stringify(data).replace(/</g, "\\u003c")
42
- });
43
+ for (const item of jsonLd(seo)) {
44
+ tags.push({ tag: "script", attrs: { type: "application/ld+json" }, content: item.json });
43
45
  }
44
46
  return tags;
45
47
  }
package/dist/astro.js CHANGED
@@ -1,5 +1,6 @@
1
- import { headTags } from './chunk-SSDAREDA.js';
2
- export { headTagList, headTags } from './chunk-SSDAREDA.js';
1
+ import { headTags } from './chunk-QZXUMDB7.js';
2
+ export { headTagList, headTags } from './chunk-QZXUMDB7.js';
3
+ import './chunk-N3QOL5EU.js';
3
4
  import './chunk-PKBMQBKP.js';
4
5
 
5
6
  // src/astro.ts
@@ -0,0 +1,10 @@
1
+ // src/structured-data.ts
2
+ var jsonLdText = (data) => JSON.stringify(data).replace(/</g, "\\u003c");
3
+ function jsonLd(seo) {
4
+ return (seo.structuredData ?? []).map((data) => ({ data, json: jsonLdText(data) }));
5
+ }
6
+ function jsonLdHtml(seo) {
7
+ return jsonLd(seo).map((d) => `<script type="application/ld+json">${d.json}</script>`).join("\n");
8
+ }
9
+
10
+ export { jsonLd, jsonLdHtml };
@@ -1,3 +1,5 @@
1
+ import { jsonLd } from './chunk-N3QOL5EU.js';
2
+
1
3
  // src/html.ts
2
4
  function headTagList(seo, opts = {}) {
3
5
  const tags = [{ tag: "title", attrs: {}, content: seo.title }];
@@ -32,12 +34,8 @@ function headTagList(seo, opts = {}) {
32
34
  meta("name", "twitter:description", tw.description);
33
35
  meta("name", "twitter:image", tw.image);
34
36
  if (seo.favicon) tags.push({ tag: "link", attrs: { rel: "icon", href: seo.favicon } });
35
- for (const data of seo.structuredData) {
36
- tags.push({
37
- tag: "script",
38
- attrs: { type: "application/ld+json" },
39
- content: JSON.stringify(data).replace(/</g, "\\u003c")
40
- });
37
+ for (const item of jsonLd(seo)) {
38
+ tags.push({ tag: "script", attrs: { type: "application/ld+json" }, content: item.json });
41
39
  }
42
40
  return tags;
43
41
  }
package/dist/html.cjs CHANGED
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ // src/structured-data.ts
4
+ var jsonLdText = (data) => JSON.stringify(data).replace(/</g, "\\u003c");
5
+ function jsonLd(seo) {
6
+ return (seo.structuredData ?? []).map((data) => ({ data, json: jsonLdText(data) }));
7
+ }
8
+
3
9
  // src/html.ts
4
10
  function headTagList(seo, opts = {}) {
5
11
  const tags = [{ tag: "title", attrs: {}, content: seo.title }];
@@ -34,12 +40,8 @@ function headTagList(seo, opts = {}) {
34
40
  meta("name", "twitter:description", tw.description);
35
41
  meta("name", "twitter:image", tw.image);
36
42
  if (seo.favicon) tags.push({ tag: "link", attrs: { rel: "icon", href: seo.favicon } });
37
- for (const data of seo.structuredData) {
38
- tags.push({
39
- tag: "script",
40
- attrs: { type: "application/ld+json" },
41
- content: JSON.stringify(data).replace(/</g, "\\u003c")
42
- });
43
+ for (const item of jsonLd(seo)) {
44
+ tags.push({ tag: "script", attrs: { type: "application/ld+json" }, content: item.json });
43
45
  }
44
46
  return tags;
45
47
  }
package/dist/html.js CHANGED
@@ -1,2 +1,3 @@
1
- export { headTagList, headTags, renderTag } from './chunk-SSDAREDA.js';
1
+ export { headTagList, headTags, renderTag } from './chunk-QZXUMDB7.js';
2
+ import './chunk-N3QOL5EU.js';
2
3
  import './chunk-PKBMQBKP.js';
package/dist/index.cjs CHANGED
@@ -196,6 +196,15 @@ function checkSections(files, pages = {}) {
196
196
  return warnings;
197
197
  }
198
198
 
199
+ // src/structured-data.ts
200
+ var jsonLdText = (data) => JSON.stringify(data).replace(/</g, "\\u003c");
201
+ function jsonLd(seo) {
202
+ return (seo.structuredData ?? []).map((data) => ({ data, json: jsonLdText(data) }));
203
+ }
204
+ function jsonLdHtml(seo) {
205
+ return jsonLd(seo).map((d) => `<script type="application/ld+json">${d.json}</script>`).join("\n");
206
+ }
207
+
199
208
  // src/index.ts
200
209
  var RETRY_AFTER_CAP_MS = 1e4;
201
210
  var SITE_TTL_MS = 6e4;
@@ -331,6 +340,8 @@ exports.createBrease = createBrease;
331
340
  exports.ga4Html = ga4Html;
332
341
  exports.ga4Tag = ga4Tag;
333
342
  exports.grantAnalytics = grantAnalytics;
343
+ exports.jsonLd = jsonLd;
344
+ exports.jsonLdHtml = jsonLdHtml;
334
345
  exports.localeHref = localeHref;
335
346
  exports.localeLinks = localeLinks;
336
347
  exports.nativeName = nativeName;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Site, U as UrlSettings, P as Page, a as PageRef, N as Navigation, b as Redirect, c as Release, d as SitemapEntry } from './types-ecfDXrLa.cjs';
2
- export { L as LocaleStrategy, e as NavigationItem, O as OpenGraph, f as PageSeo, R as ResolvedSeo, g as Robots, h as SiteSeo, T as Twitter } from './types-ecfDXrLa.cjs';
1
+ import { S as Site, U as UrlSettings, R as ResolvedSeo, P as Page, a as PageRef, N as Navigation, b as Redirect, c as Release, d as SitemapEntry } from './types-ecfDXrLa.cjs';
2
+ export { L as LocaleStrategy, e as NavigationItem, O as OpenGraph, f as PageSeo, g as Robots, h as SiteSeo, T as Twitter } from './types-ecfDXrLa.cjs';
3
3
 
4
4
  type Ga4Tag = {
5
5
  id: string;
@@ -49,6 +49,13 @@ type PageLocales = Record<string, Record<string, {
49
49
  }>>;
50
50
  declare function checkSections(files: Record<string, string>, pages?: PageLocales): string[];
51
51
 
52
+ type JsonLd = {
53
+ data: Record<string, unknown>;
54
+ json: string;
55
+ };
56
+ declare function jsonLd(seo: Pick<ResolvedSeo, 'structuredData'>): JsonLd[];
57
+ declare function jsonLdHtml(seo: Pick<ResolvedSeo, 'structuredData'>): string;
58
+
52
59
  declare function normalizeSlug(input: string): string;
53
60
  declare function buildPath(settings: UrlSettings, slug: string, locale: string): string;
54
61
  declare function resolvePath(settings: UrlSettings, pathname: string): {
@@ -99,4 +106,4 @@ interface Brease {
99
106
  }
100
107
  declare function createBrease(opts?: BreaseOptions): Brease;
101
108
 
102
- export { type Brease, BreaseError, type BreaseOptions, type BreaseSection, type Ga4Tag, type LocaleContext, type LocaleLink, Navigation, Page, PageRef, Redirect, Release, Site, SitemapEntry, UrlSettings, buildPath, checkSections, createBrease, ga4Html, ga4Tag, grantAnalytics, localeHref, localeLinks, nativeName, normalizeSlug, resolvePath, sectionAttrs, sectionsAttrs };
109
+ export { type Brease, BreaseError, type BreaseOptions, type BreaseSection, type Ga4Tag, type JsonLd, type LocaleContext, type LocaleLink, Navigation, Page, PageRef, Redirect, Release, ResolvedSeo, Site, SitemapEntry, UrlSettings, buildPath, checkSections, createBrease, ga4Html, ga4Tag, grantAnalytics, jsonLd, jsonLdHtml, localeHref, localeLinks, nativeName, normalizeSlug, resolvePath, sectionAttrs, sectionsAttrs };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Site, U as UrlSettings, P as Page, a as PageRef, N as Navigation, b as Redirect, c as Release, d as SitemapEntry } from './types-ecfDXrLa.js';
2
- export { L as LocaleStrategy, e as NavigationItem, O as OpenGraph, f as PageSeo, R as ResolvedSeo, g as Robots, h as SiteSeo, T as Twitter } from './types-ecfDXrLa.js';
1
+ import { S as Site, U as UrlSettings, R as ResolvedSeo, P as Page, a as PageRef, N as Navigation, b as Redirect, c as Release, d as SitemapEntry } from './types-ecfDXrLa.js';
2
+ export { L as LocaleStrategy, e as NavigationItem, O as OpenGraph, f as PageSeo, g as Robots, h as SiteSeo, T as Twitter } from './types-ecfDXrLa.js';
3
3
 
4
4
  type Ga4Tag = {
5
5
  id: string;
@@ -49,6 +49,13 @@ type PageLocales = Record<string, Record<string, {
49
49
  }>>;
50
50
  declare function checkSections(files: Record<string, string>, pages?: PageLocales): string[];
51
51
 
52
+ type JsonLd = {
53
+ data: Record<string, unknown>;
54
+ json: string;
55
+ };
56
+ declare function jsonLd(seo: Pick<ResolvedSeo, 'structuredData'>): JsonLd[];
57
+ declare function jsonLdHtml(seo: Pick<ResolvedSeo, 'structuredData'>): string;
58
+
52
59
  declare function normalizeSlug(input: string): string;
53
60
  declare function buildPath(settings: UrlSettings, slug: string, locale: string): string;
54
61
  declare function resolvePath(settings: UrlSettings, pathname: string): {
@@ -99,4 +106,4 @@ interface Brease {
99
106
  }
100
107
  declare function createBrease(opts?: BreaseOptions): Brease;
101
108
 
102
- export { type Brease, BreaseError, type BreaseOptions, type BreaseSection, type Ga4Tag, type LocaleContext, type LocaleLink, Navigation, Page, PageRef, Redirect, Release, Site, SitemapEntry, UrlSettings, buildPath, checkSections, createBrease, ga4Html, ga4Tag, grantAnalytics, localeHref, localeLinks, nativeName, normalizeSlug, resolvePath, sectionAttrs, sectionsAttrs };
109
+ export { type Brease, BreaseError, type BreaseOptions, type BreaseSection, type Ga4Tag, type JsonLd, type LocaleContext, type LocaleLink, Navigation, Page, PageRef, Redirect, Release, ResolvedSeo, Site, SitemapEntry, UrlSettings, buildPath, checkSections, createBrease, ga4Html, ga4Tag, grantAnalytics, jsonLd, jsonLdHtml, localeHref, localeLinks, nativeName, normalizeSlug, resolvePath, sectionAttrs, sectionsAttrs };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export { BreaseError, buildPath, createBrease, ga4Html, ga4Tag, grantAnalytics, localeHref, localeLinks, nativeName, normalizeSlug, resolvePath } from './chunk-7BBL2LET.js';
1
+ export { BreaseError, buildPath, createBrease, ga4Html, ga4Tag, grantAnalytics, localeHref, localeLinks, nativeName, normalizeSlug, resolvePath } from './chunk-GJ3SOWDB.js';
2
2
  export { checkSections, sectionAttrs, sectionsAttrs } from './chunk-CQZLTZGN.js';
3
+ export { jsonLd, jsonLdHtml } from './chunk-N3QOL5EU.js';
3
4
  import './chunk-PKBMQBKP.js';
package/dist/next.js CHANGED
@@ -1,5 +1,6 @@
1
- import { env, createBrease } from './chunk-7BBL2LET.js';
1
+ import { env, createBrease } from './chunk-GJ3SOWDB.js';
2
2
  import './chunk-CQZLTZGN.js';
3
+ import './chunk-N3QOL5EU.js';
3
4
  import './chunk-PKBMQBKP.js';
4
5
 
5
6
  // src/next.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brease-client",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Brease delivery API client for Next.js, Astro and any fetch-capable runtime",
5
5
  "license": "MIT",
6
6
  "repository": {
File without changes