@the-smithy/hearth 0.24.0 → 0.25.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.
@@ -73,7 +73,7 @@ function createCore(options) {
73
73
  throw new Error("Hearth: the API key is secret, so the client only runs on the server. Fetch content in server code, or pass allowBrowser: true if you understand the risk.");
74
74
  }
75
75
  const baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
76
- const doFetch = options.fetch ?? globalThis.fetch;
76
+ const doFetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
77
77
  const timeoutMs = options.timeoutMs ?? 1e4;
78
78
  const retries = options.retries ?? 2;
79
79
  const hooks = options.hooks ?? {};
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  findRedirect,
6
6
  isHearthError,
7
7
  normalizeSlug
8
- } from "./chunk-GTKPZN53.js";
8
+ } from "./chunk-3LZQGXTQ.js";
9
9
 
10
10
  // src/index.ts
11
11
  import { videoEmbedUrl } from "@the-smithy/hearth-schema";
package/dist/next.d.ts CHANGED
@@ -254,7 +254,7 @@ declare function createHearthNext(client: HearthCore, { tag, revalidate }?: Hear
254
254
  sitemap(): Promise<MetadataRoute.Sitemap>;
255
255
  /**
256
256
  * Hearth's sitemap plus pages the site's own code serves (an events calendar, a donate page), skipping any
257
- * Hearth already lists:
257
+ * Hearth already lists and any that a page in Hearth at that address hides from search engines:
258
258
  * export default hearthNext.sitemapWith(["/events", "/fundraisers"]);
259
259
  */
260
260
  sitemapWith(paths: string[]): () => Promise<MetadataRoute.Sitemap>;
package/dist/next.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  findRedirect,
3
3
  isHearthError,
4
4
  normalizeSlug
5
- } from "./chunk-GTKPZN53.js";
5
+ } from "./chunk-3LZQGXTQ.js";
6
6
  import {
7
7
  parseWebhook,
8
8
  tagsForWebhook
@@ -276,15 +276,15 @@ function createHearthNext(client, { tag = "hearth", revalidate = 3600 } = {}) {
276
276
  },
277
277
  /**
278
278
  * Hearth's sitemap plus pages the site's own code serves (an events calendar, a donate page), skipping any
279
- * Hearth already lists:
279
+ * Hearth already lists and any that a page in Hearth at that address hides from search engines:
280
280
  * export default hearthNext.sitemapWith(["/events", "/fundraisers"]);
281
281
  */
282
282
  sitemapWith(paths) {
283
283
  return async () => {
284
- const [entries, site] = await Promise.all([client.sitemap(tags(`${tag}:pages`, `${tag}:events`)), client.site.get(tags(`${tag}:site`))]);
284
+ const [entries, site, pages] = await Promise.all([client.sitemap(tags(`${tag}:pages`, `${tag}:events`)), client.site.get(tags(`${tag}:site`)), client.pages.list(tags(`${tag}:pages`))]);
285
285
  const base = siteBaseUrl(site) ?? "";
286
- const listed = new Set(entries.map((e) => e.path));
287
- const extra = site.settings.seo.noIndex ? [] : paths.filter((p) => !listed.has(p)).map((p) => ({ url: `${base}${p}`, priority: 0.6 }));
286
+ const skip = /* @__PURE__ */ new Set([...entries.map((e) => e.path), ...pages.filter((p) => p.noIndex).map((p) => p.path)]);
287
+ const extra = site.settings.seo.noIndex ? [] : paths.filter((p) => !skip.has(p)).map((p) => ({ url: `${base}${p}`, priority: 0.6 }));
288
288
  return [...entries.map((e) => ({ url: e.url, ...e.lastModified ? { lastModified: e.lastModified } : {}, priority: e.priority })), ...extra];
289
289
  };
290
290
  },
package/dist/testing.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/testing.ts
2
+ import { isUnlistedPage } from "@the-smithy/hearth-schema";
2
3
  var json = (body, status = 200) => new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
3
4
  var notFound = () => json({ error: { code: "not_found", message: "Not found" } }, 404);
4
5
  function createMockHearth(data = {}) {
@@ -30,7 +31,7 @@ function createMockHearth(data = {}) {
30
31
  return result.ok ? json({ data: { message: result.message } }, 201) : json({ error: { code: "bad_request", message: result.message, details: result.fieldErrors } }, 400);
31
32
  }
32
33
  if (rest === "") return json({ data: { slug, name: slug, domain: null, features: [], settings: {}, ...data.site } });
33
- if (rest === "/pages") return json({ data: (data.pages ?? []).map(({ slug: slug2, path, title, seo, publishedAt }) => ({ slug: slug2, path, title, seo, noIndex: false, publishedAt })) });
34
+ if (rest === "/pages") return json({ data: (data.pages ?? []).map(({ slug: slug2, path, title, seo, publishedAt }) => ({ slug: slug2, path, title, seo, noIndex: Boolean(seo?.noIndex) || isUnlistedPage(slug2), publishedAt })) });
34
35
  if (rest.startsWith("/pages/")) {
35
36
  const pool = req.headers.get("x-hearth-preview") ? [...data.draftPages ?? [], ...data.pages ?? []] : data.pages ?? [];
36
37
  const page = pool.find((p) => p.slug === decodeURIComponent(rest.slice(7)));
package/llms.md CHANGED
@@ -62,6 +62,7 @@ client components: the API key is secret.
62
62
  - `PageMeta`: `fullTitle`, `title`, `description`, `canonical`, `robots { index, follow }`,
63
63
  `openGraph`, `twitter`, `image { url, width, height, alt }`, `jsonLd[]`.
64
64
  - Each block is `{ id, type, data }`; fields live on `data`. Narrow by `type`; use `BlockOf<"hero">` for one type.
65
+ - Any block may have `anchor` (beside `type`): make it the `id` of its outermost element, so `/#anchor` links reach it.
65
66
  - Unknown future types arrive as `UnknownBlock`. Always handle a fallback.
66
67
  - Images are `ImageRef = { src, alt, width?, height?, focal?: { x, y } }`. `focal` is the spot to keep in view when the
67
68
  image is cropped (percentages across and down, set in Hearth's media library). For an image with `object-fit: cover`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-smithy/hearth",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "Typed client for the Hearth Delivery API: content, SEO, forms and publish webhooks.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -49,7 +49,7 @@
49
49
  "llms.md"
50
50
  ],
51
51
  "dependencies": {
52
- "@the-smithy/hearth-schema": "^0.24.0"
52
+ "@the-smithy/hearth-schema": "^0.25.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "next": ">=15",