@the-smithy/hearth 0.21.0 → 0.22.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/dist/{chunk-V47RFBJE.js → chunk-RZNKY7HG.js} +5 -0
- package/dist/{client-IImehdSM.d.ts → client-BXkB1aKA.d.ts} +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/next.d.ts +7 -1
- package/dist/next.js +13 -1
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +1 -0
- package/llms.md +4 -1
- package/package.json +2 -2
|
@@ -239,6 +239,11 @@ function createCore(options) {
|
|
|
239
239
|
}
|
|
240
240
|
},
|
|
241
241
|
sitemap: (o = {}) => request("/sitemap", { ...o, resource: "sitemap" }),
|
|
242
|
+
/**
|
|
243
|
+
* The site's llms.txt (Markdown for AI tools: the organization, how to reach it, its pages with a line on each),
|
|
244
|
+
* or null while the site has no domain or is hidden from search engines, and from Hearth versions without it.
|
|
245
|
+
*/
|
|
246
|
+
llmsTxt: async (o = {}) => await maybe("/llms", { ...o, resource: "llms" }) ?? null,
|
|
242
247
|
redirects: {
|
|
243
248
|
/** Every redirect on the site (old addresses and where they go now). Empty from Hearth versions without them. */
|
|
244
249
|
list: async (o = {}) => await maybe("/redirects", { ...o, resource: "redirects.list" }) ?? []
|
|
@@ -178,6 +178,11 @@ declare function createCore(options: HearthClientOptions): {
|
|
|
178
178
|
}, o?: CallOptions) => Promise<CollectionPage | EventCollectionPage | null>;
|
|
179
179
|
};
|
|
180
180
|
sitemap: (o?: CallOptions) => Promise<SitemapEntry[]>;
|
|
181
|
+
/**
|
|
182
|
+
* The site's llms.txt (Markdown for AI tools: the organization, how to reach it, its pages with a line on each),
|
|
183
|
+
* or null while the site has no domain or is hidden from search engines, and from Hearth versions without it.
|
|
184
|
+
*/
|
|
185
|
+
llmsTxt: (o?: CallOptions) => Promise<string | null>;
|
|
181
186
|
redirects: {
|
|
182
187
|
/** Every redirect on the site (old addresses and where they go now). Empty from Hearth versions without them. */
|
|
183
188
|
list: (o?: CallOptions) => Promise<Redirect[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HearthCore, a as HearthClientOptions } from './client-
|
|
2
|
-
export { C as CallOptions, b as CollectionPage, D as DEFAULT_BASE_URL, E as EventCollectionPage, F as FormResult, c as FormValues, d as HearthError, e as HearthErrorCode, f as HearthHooks, N as NextFetchOptions, P as PreviewSession, R as RequestContext, g as RequestOptions, h as findRedirect, i as isHearthError, n as normalizeSlug } from './client-
|
|
1
|
+
import { H as HearthCore, a as HearthClientOptions } from './client-BXkB1aKA.js';
|
|
2
|
+
export { C as CallOptions, b as CollectionPage, D as DEFAULT_BASE_URL, E as EventCollectionPage, F as FormResult, c as FormValues, d as HearthError, e as HearthErrorCode, f as HearthHooks, N as NextFetchOptions, P as PreviewSession, R as RequestContext, g as RequestOptions, h as findRedirect, i as isHearthError, n as normalizeSlug } from './client-BXkB1aKA.js';
|
|
3
3
|
export { AnalyticsReport, AnalyticsRow, Block, BlockOf, CategoryGroup, CategoryRef, Collection, CollectionEntry, CollectionRef, DonationCheckout, DonationInput, EntryDetails, EventCustomFields, EventRegistration, EventTicket, EventVolunteerShift, EventVolunteering, Fundraiser, FundraiserDetail, HearthEvent, HearthEventDetail, ImageRef, KnownBlock, Page, PageMeta, PageSummary, Position, Redirect, RegistrationInput, RegistrationResult, ResolvedBlock, Site, SiteAnalytics, SiteSettings, SitemapEntry, UnknownBlock, VolunteerInput, VolunteerResult, WebhookPayload, directionsUrl, focalPosition, pinned, videoEmbedUrl } from '@the-smithy/hearth-schema';
|
|
4
4
|
|
|
5
5
|
/** A plugin adds resources (and can use the core's `request`) under its own names. */
|
package/dist/index.js
CHANGED
package/dist/next.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HearthCore, b as CollectionPage, E as EventCollectionPage, F as FormResult, c as FormValues } from './client-
|
|
1
|
+
import { H as HearthCore, b as CollectionPage, E as EventCollectionPage, F as FormResult, c as FormValues } from './client-BXkB1aKA.js';
|
|
2
2
|
import * as _the_smithy_hearth_schema from '@the-smithy/hearth-schema';
|
|
3
3
|
import { Site, PageMeta } from '@the-smithy/hearth-schema';
|
|
4
4
|
import { Metadata, MetadataRoute } from 'next';
|
|
@@ -254,6 +254,12 @@ declare function createHearthNext(client: HearthCore, { tag, revalidate }?: Hear
|
|
|
254
254
|
* export default hearthNext.sitemapWith(["/events", "/fundraisers"]);
|
|
255
255
|
*/
|
|
256
256
|
sitemapWith(paths: string[]): () => Promise<MetadataRoute.Sitemap>;
|
|
257
|
+
/**
|
|
258
|
+
* GET handler for app/llms.txt/route.ts, the summary AI tools read (https://llmstxt.org):
|
|
259
|
+
* export const GET = hearthNext.llmsTxtHandler();
|
|
260
|
+
* Not found until the site has a domain in Hearth, while it's hidden from search engines, and on preview deploys.
|
|
261
|
+
*/
|
|
262
|
+
llmsTxtHandler(): () => Promise<Response>;
|
|
257
263
|
/**
|
|
258
264
|
* POST handler for the site's revalidation webhook (app/api/revalidate/route.ts):
|
|
259
265
|
* export const POST = hearthNext.revalidateHandler();
|
package/dist/next.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
findRedirect,
|
|
3
3
|
isHearthError,
|
|
4
4
|
normalizeSlug
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RZNKY7HG.js";
|
|
6
6
|
import {
|
|
7
7
|
parseWebhook,
|
|
8
8
|
tagsForWebhook
|
|
@@ -284,6 +284,18 @@ function createHearthNext(client, { tag = "hearth", revalidate = 3600 } = {}) {
|
|
|
284
284
|
return [...entries.map((e) => ({ url: e.url, ...e.lastModified ? { lastModified: e.lastModified } : {}, priority: e.priority })), ...extra];
|
|
285
285
|
};
|
|
286
286
|
},
|
|
287
|
+
/**
|
|
288
|
+
* GET handler for app/llms.txt/route.ts, the summary AI tools read (https://llmstxt.org):
|
|
289
|
+
* export const GET = hearthNext.llmsTxtHandler();
|
|
290
|
+
* Not found until the site has a domain in Hearth, while it's hidden from search engines, and on preview deploys.
|
|
291
|
+
*/
|
|
292
|
+
llmsTxtHandler() {
|
|
293
|
+
return async () => {
|
|
294
|
+
const text = isNonProductionDeploy() ? null : await client.llmsTxt(tags(`${tag}:pages`, `${tag}:events`, `${tag}:site`));
|
|
295
|
+
if (!text) return new Response("Not found", { status: 404, headers: { "Content-Type": "text/plain; charset=utf-8" } });
|
|
296
|
+
return new Response(text, { headers: { "Content-Type": "text/markdown; charset=utf-8" } });
|
|
297
|
+
};
|
|
298
|
+
},
|
|
287
299
|
/**
|
|
288
300
|
* POST handler for the site's revalidation webhook (app/api/revalidate/route.ts):
|
|
289
301
|
* export const POST = hearthNext.revalidateHandler();
|
package/dist/testing.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ type MockHearthData = {
|
|
|
5
5
|
pages?: Page[];
|
|
6
6
|
events?: (HearthEvent | HearthEventDetail)[];
|
|
7
7
|
sitemap?: SitemapEntry[];
|
|
8
|
+
/** The site's llms.txt; null (the default) is a site without one. */
|
|
9
|
+
llmsTxt?: string | null;
|
|
8
10
|
redirects?: Redirect[];
|
|
9
11
|
/** Collections, with their entries (page collections) keyed by collection slug. */
|
|
10
12
|
collections?: Collection[];
|
package/dist/testing.js
CHANGED
|
@@ -46,6 +46,7 @@ function createMockHearth(data = {}) {
|
|
|
46
46
|
return event ? json({ data: event }) : notFound();
|
|
47
47
|
}
|
|
48
48
|
if (rest === "/sitemap") return json({ data: data.sitemap ?? [] });
|
|
49
|
+
if (rest === "/llms") return json({ data: data.llmsTxt ?? null });
|
|
49
50
|
if (rest === "/redirects") return json({ data: data.redirects ?? [] });
|
|
50
51
|
if (rest === "/fundraisers" || rest.startsWith("/fundraisers?")) {
|
|
51
52
|
const status = url.searchParams.get("status") ?? "active";
|
package/llms.md
CHANGED
|
@@ -37,6 +37,7 @@ client components: the API key is secret.
|
|
|
37
37
|
- `events.list({ when?: "upcoming" | "past", limit? }): HearthEvent[]`
|
|
38
38
|
- `events.get(slug): HearthEventDetail | null`
|
|
39
39
|
- `sitemap(): SitemapEntry[]`
|
|
40
|
+
- `llmsTxt(): string | null`: the site's llms.txt (Markdown for AI tools), null while it has no domain or is hidden
|
|
40
41
|
- `forms.get(formKey): HearthForm | null`: the site's form (`{ key, name, fields, submitLabel, successMessage }`), to render outside a Form block, e.g. in a footer. Each site has one form, `contact`, and every Form block shows it. Fields are `{ name, label, type, required, options?, placeholder? }`; render `placeholder` in the input (for a select, as the prompt option). A Form block can instead name an Ember form (`data.emberFormId`, `frm_…`): render it with `EmberForm` from `@the-smithy/ember/react`, with the site's form as the fallback.
|
|
41
42
|
- `forms.submit(formKey, FormData | object, { ip? }): { ok: true, message } | { ok: false, message, fieldErrors }`
|
|
42
43
|
- `request<T>(path, opts)`: the raw call for anything else under `/api/v1/sites/{site}`
|
|
@@ -78,6 +79,8 @@ client components: the API key is secret.
|
|
|
78
79
|
- `generateMetadata`: `return hearthNext.generatePageMetadata((await params).slug)`
|
|
79
80
|
- Events: `metadataFromMeta(event.meta)`
|
|
80
81
|
- `app/sitemap.ts`: `export default hearthNext.sitemap`
|
|
82
|
+
- `app/llms.txt/route.ts`: `export const GET = hearthNext.llmsTxtHandler()` (the organization, contact details,
|
|
83
|
+
hours and every listed page with a line on it, for AI tools; 404 on previews and while the site is hidden)
|
|
81
84
|
- `app/api/revalidate/route.ts`: `export const POST = hearthNext.revalidateHandler()`
|
|
82
85
|
- Giving: `getFundraisers(opts)`, `getFundraiser(slug)`, and a donation form's server action:
|
|
83
86
|
`export const donate = async (prev: FormResult | null, fd: FormData) => hearthNext.donateAction()(prev, fd)`
|
|
@@ -113,5 +116,5 @@ client components: the API key is secret.
|
|
|
113
116
|
## Other entry points
|
|
114
117
|
- `@the-smithy/hearth/webhooks`: `verifyWebhook(raw, header, secret)`, `parseWebhook(request, secret)`,
|
|
115
118
|
`tagsForWebhook(payload)`
|
|
116
|
-
- `@the-smithy/hearth/testing`: `createMockHearth({ site, pages, events, sitemap, onForm })` returns
|
|
119
|
+
- `@the-smithy/hearth/testing`: `createMockHearth({ site, pages, events, sitemap, llmsTxt, onForm })` returns
|
|
117
120
|
`{ fetch, requests }`. Pass `fetch` to `createHearthClient`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@the-smithy/hearth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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.
|
|
52
|
+
"@the-smithy/hearth-schema": "^0.22.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"next": ">=15",
|