@tdacorp/hyle-sdk 0.12.0 → 0.17.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.
Files changed (43) hide show
  1. package/README.md +46 -12
  2. package/dist/check-routes-bin.js +31 -18
  3. package/dist/{chunk-S7PCCEHP.js → chunk-6VOHFFA5.js} +4 -3
  4. package/dist/{chunk-ZQFYH4FX.js → chunk-DMK4XQLU.js} +497 -327
  5. package/dist/{chunk-N7ZQUAGM.js → chunk-MGSUQBDW.js} +19 -7
  6. package/dist/{chunk-R5EMI4HQ.js → chunk-PJMJMP66.js} +3 -1
  7. package/dist/comments.cjs +6 -4
  8. package/dist/comments.js +6 -5
  9. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-FJPED4SN.js} +46 -26
  10. package/dist/{embed-jCaSI31t.d.cts → embed-BmdwA2G9.d.cts} +51 -5
  11. package/dist/{embed-DL5QIZRJ.d.ts → embed-DNTZ2UXv.d.ts} +51 -5
  12. package/dist/index.cjs +19 -7
  13. package/dist/index.d.cts +15 -8
  14. package/dist/index.d.ts +15 -8
  15. package/dist/index.js +1 -1
  16. package/dist/labels-nmukKYgL.d.cts +37 -0
  17. package/dist/labels-nmukKYgL.d.ts +37 -0
  18. package/dist/mermaid-diagram.cjs +59 -30
  19. package/dist/mermaid-diagram.d.cts +4 -37
  20. package/dist/mermaid-diagram.d.ts +4 -37
  21. package/dist/mermaid-diagram.js +7 -5
  22. package/dist/mermaid-image.cjs +1382 -0
  23. package/dist/mermaid-image.d.cts +29 -0
  24. package/dist/mermaid-image.d.ts +29 -0
  25. package/dist/mermaid-image.js +94 -0
  26. package/dist/next.cjs +1235 -789
  27. package/dist/next.d.cts +149 -24
  28. package/dist/next.d.ts +149 -24
  29. package/dist/next.js +887 -612
  30. package/dist/react.cjs +336 -196
  31. package/dist/react.d.cts +39 -7
  32. package/dist/react.d.ts +39 -7
  33. package/dist/react.js +1 -1
  34. package/dist/{resolve-DvmuBlpO.d.ts → resolve-Ae7UFjsQ.d.ts} +5 -5
  35. package/dist/{resolve-f6IJ6SL9.d.cts → resolve-euZ4-aC9.d.cts} +5 -5
  36. package/dist/styles.css +11 -22
  37. package/dist/{types-5D6ZD0Wi.d.cts → types-Czt887Iv.d.cts} +32 -3
  38. package/dist/{types-5D6ZD0Wi.d.ts → types-Czt887Iv.d.ts} +32 -3
  39. package/dist/use-cache.cjs +1 -1
  40. package/dist/use-cache.d.cts +2 -2
  41. package/dist/use-cache.d.ts +2 -2
  42. package/dist/use-cache.js +2 -2
  43. package/package.json +1 -1
package/dist/next.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ReactElement } from 'react';
2
- import { H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-jCaSI31t.cjs';
3
- export { c as HyleCommentsFallback } from './embed-jCaSI31t.cjs';
4
- import { F as FetchResolverOptions, H as HyleResolver } from './resolve-f6IJ6SL9.cjs';
5
- export { f as fetchResolver, w as workspaceTags } from './resolve-f6IJ6SL9.cjs';
6
- import { MetadataRoute, Metadata } from 'next';
2
+ import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-BmdwA2G9.cjs';
3
+ export { c as HyleCommentsFallback } from './embed-BmdwA2G9.cjs';
4
+ import { F as FetchResolverOptions, H as HyleResolver } from './resolve-euZ4-aC9.cjs';
5
+ export { f as fetchResolver, w as workspaceTags } from './resolve-euZ4-aC9.cjs';
6
+ import { MetadataRoute, ResolvingMetadata, Metadata } from 'next';
7
7
  import { a as RevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.cjs';
8
- import './types-5D6ZD0Wi.cjs';
8
+ import './types-Czt887Iv.cjs';
9
9
 
10
10
  type RouteParams = Record<string, string | string[] | undefined>;
11
11
  interface CommonOptions {
@@ -31,6 +31,57 @@ interface CommonOptions {
31
31
  * same origin you give `hyleSitemap`.
32
32
  */
33
33
  readonly siteOrigin?: string;
34
+ /**
35
+ * The Open Graph / Twitter card image of an article. Return an absolute https URL, or a root-relative path (joined onto
36
+ * `siteOrigin`); anything invalid, or a relative path without a valid `siteOrigin`, is omitted rather than emitted broken.
37
+ * The same image becomes the BlogPosting `image`. Unset, see `ogImageRoute`.
38
+ */
39
+ readonly ogImage?: (article: ArticleRef) => OgImage | undefined;
40
+ /**
41
+ * "More in this section" under article pages (layout "article"): one extra list request of the article's section, the current
42
+ * article left out, rendered after the pager, plus the article's own child pages when it has any. `limit` is the number of
43
+ * related articles (default 5, at most 100), `title` the heading (default localized). A failed request renders nothing.
44
+ */
45
+ readonly related?: {
46
+ readonly limit?: number;
47
+ readonly title?: string;
48
+ };
49
+ /**
50
+ * Use the generated card as the article image when `ogImage` is unset and `siteOrigin` is valid: `/api/hyle/og/<canonical path>?locale=`.
51
+ * Opt-in because it needs `createOgImageRoute` mounted at `app/api/hyle/og/[...path]/route.ts`; without it the URL would 404. Default false.
52
+ */
53
+ readonly ogImageRoute?: boolean;
54
+ /**
55
+ * Where the host mounted `hyleFeed` (for example "/feed.xml", or a function of the locale). With it, article and list metadata carry
56
+ * `<link rel="alternate" type="application/rss+xml">` (absolute with `siteOrigin`; the path is not localized, so return the locale's own feed path from the function form if feeds are per-locale, which receives the page's locale and is skipped when none is configured); `hyleFeedLink` gives the same link for a host-owned page.
57
+ * `title` defaults to "<siteName> feed", else "Feed". Unset: no link.
58
+ */
59
+ readonly feed?: {
60
+ readonly path: string | ((locale: string) => string);
61
+ readonly title?: string;
62
+ };
63
+ /** Set when `createMarkdownRoute` and its middleware rewrite are mounted: article metadata then carries `<link rel="alternate" type="text/markdown">` to `<canonical>.md`. Default false. */
64
+ readonly markdownTwin?: boolean;
65
+ /** Open Graph `og:site_name`. Unset: not emitted. */
66
+ readonly siteName?: string;
67
+ /** `twitter:site` and `twitter:creator` handles (for example "@TDACorp"), emitted with the Twitter card (needs `ogImage`). Unset: not emitted. */
68
+ readonly twitter?: {
69
+ readonly site?: string;
70
+ readonly creator?: string;
71
+ };
72
+ /**
73
+ * Maps a page locale such as "en" to an Open Graph locale such as "en_US". With it, `og:locale` uses the mapped value and
74
+ * `og:locale:alternate` lists the article's other published locales (undefined results are dropped). Unset: the bare locale, no alternates.
75
+ */
76
+ readonly ogLocale?: (locale: string) => string | undefined;
77
+ /** Publisher, author and WebSite identities for the article JSON-LD graph. Needs `siteOrigin`. See `JsonLdConfig`. */
78
+ readonly jsonLd?: JsonLdConfig;
79
+ /**
80
+ * A `<title>` template such as "%s · TDACorp Learn", emitted as an absolute title (so the root layout's template does not apply
81
+ * on top) after any "Older posts" suffix. The Open Graph title and the JSON-LD headline stay the bare title. Unset: the title is as hyle gives it.
82
+ * A value without "%s" is ignored.
83
+ */
84
+ readonly titleTemplate?: string;
34
85
  readonly components?: HyleComponents;
35
86
  readonly slots?: HyleSlots;
36
87
  /**
@@ -108,35 +159,45 @@ declare function hylePage(options: HyleNextOptions): (props: PageProps) => Promi
108
159
  type HyleSitemapOptions = HyleNextOptions & {
109
160
  /** The site's public origin, for example "https://tdacorp.in": https, no path, query or credentials. */
110
161
  readonly origin: string;
111
- /** Section slugs to include besides the default section (their index must be `basePath/<slug>`). */
112
- readonly sections?: readonly string[];
113
162
  /**
114
163
  * What to do when hyle fails or a listing is cut off. `"partial"`: return what was collected. `"throw"`: throw, so a build
115
164
  * during a hyle outage fails instead of shipping a partial sitemap. Default: throw only when nothing was collected.
116
165
  */
117
166
  readonly onIncomplete?: "partial" | "throw";
167
+ /**
168
+ * The workspace default locale. Set, a translated entry's `alternates.languages` also carries `x-default` (the default-locale
169
+ * member's URL, else the entry's own), exactly as the page's hreflang does. `hyleRootSitemap` passes it from the mounts.
170
+ */
171
+ readonly defaultLocale?: string;
118
172
  };
119
173
  /**
120
174
  * Sitemap entries for the mount, to spread into the host's `app/sitemap.ts`: `[...staticEntries, ...(await hyleSitemap({ ...sameOptionsAsHylePage, origin }))]`.
121
175
  * Uses the same resolver (so the same cache and tags) as `hylePage`, and `localePrefix` for the URLs. `locale` is used only
122
176
  * when it is a string: a function of the route params is never called here, so the sitemap is for the default locale.
123
- * It pages each section index through `listPublicationPaths`, so only the default section and the listed `sections` appear,
124
- * at most 2000 pages per section; paths are percent-encoded and `lastModified` is the publish time (omitted if it is not an
125
- * ISO date). An invalid `origin` throws; see `onIncomplete` for hyle failures.
177
+ * It pages each section index through `listPublicationPaths`, so only the mount's own section appears,
178
+ * at most 2000 pages; paths are percent-encoded and `lastModified` is the later of the publish and update time (omitted if neither is an
179
+ * ISO date). A translated page carries `alternates.languages` (every locale of its group, via `localePrefix`) and the entry is for the listed `locale`; `hyleRootSitemap` lists every locale of a mount. An invalid `origin` throws; see `onIncomplete` for hyle failures.
126
180
  */
127
181
  declare function hyleSitemap(options: HyleSitemapOptions): Promise<MetadataRoute.Sitemap>;
128
182
 
183
+ /** The RSS `<link rel="alternate">` for `options.feed` in `locale` (absolute with a valid `siteOrigin`), or undefined when `feed` is unset or its function form has no locale. The path is the host's own, never locale-prefixed. For a host-owned page's own metadata. */
184
+ declare function hyleFeedLink(options: HyleNextOptions, locale?: string): {
185
+ url: string;
186
+ title: string;
187
+ } | undefined;
129
188
  /**
130
- * `export const generateMetadata = hyleMetadata({ ... })` with the same options as `hylePage`. Title, description, a canonical
131
- * URL in the page's own locale (so a fallback copy under another locale prefix points at the original), hreflang alternates
132
- * from the response's `alternates` plus `x-default` (the workspace default locale's page, else the page's own), and Open Graph. A list page canonicals to itself; with `paginate` a cursor
133
- * page canonicals to its own `?cursor=` URL (never to the first page) and its title gets an "Older posts" suffix.
134
- * Paths are relative: set `metadataBase` in the host's root layout.
189
+ * `export const generateMetadata = hyleMetadata({ ... })` with the same options as `hylePage`. Title (`titleTemplate` applied last, as an
190
+ * absolute title), description, a canonical URL in the page's own locale (so a fallback copy under another locale prefix points at the
191
+ * original), hreflang alternates from the response's `alternates` (only when the translation group has two or more published members)
192
+ * plus `x-default` (the workspace default locale's page, else the page's own), and Open Graph with the `ogImage` card (and a Twitter card
193
+ * when there is one). A list page canonicals to itself; with `paginate` a cursor page canonicals to its own `?cursor=` URL (never to the
194
+ * first page) and its title gets an "Older posts" suffix. Open Graph titles are always the bare title.
195
+ * Canonical and hreflang URLs are ABSOLUTE when `siteOrigin` is a bare https origin, else relative paths (set `metadataBase` in the host's root layout).
135
196
  * Redirects, 404s and a switched-off read surface produce no metadata; `hylePage` handles those. A 4xx rejection of the request
136
197
  * gives no metadata; any other failure (network, timeout, 5xx, 401, 403, 429) is rethrown, so a transient outage is not
137
198
  * cached as a page; Next control flow is rethrown.
138
199
  */
139
- declare function hyleMetadata(options: HyleNextOptions): (props: PageProps) => Promise<Metadata>;
200
+ declare function hyleMetadata(options: HyleNextOptions): (props: PageProps, parent?: ResolvingMetadata) => Promise<Metadata>;
140
201
 
141
202
  type HyleFeedOptions = HyleNextOptions & {
142
203
  /** Items in the feed (the server maximum is 100). Default 50. */
@@ -176,7 +237,13 @@ declare function createRevalidateRoute(options: RevalidateRouteOptions): Revalid
176
237
  */
177
238
  type HyleRootConfig = Omit<Extract<HyleNextOptions, {
178
239
  resolver?: undefined;
179
- }>, "basePath">;
240
+ }>, "basePath"> & {
241
+ /**
242
+ * Per-mount overrides keyed by the mount prefix hyle reports ("/learn", or "/" for a root mount), shallow-merged over this config
243
+ * (a given `list` or `jsonLd` replaces the config's whole value). Lets one mount carry its own `titleTemplate`, `ogImage`, `jsonLd`, `list` or `siteOrigin`.
244
+ */
245
+ readonly mountOptions?: Readonly<Record<string, Partial<Pick<CommonOptions, "titleTemplate" | "list" | "ogImage" | "jsonLd" | "siteOrigin">>>>;
246
+ };
180
247
  type Configs = HyleRootConfig | readonly HyleRootConfig[];
181
248
  /** How long a mounts copy that could not be refreshed may still be used. Past this a transient failure is rethrown. */
182
249
  declare const MOUNTS_MAX_STALE_MS: number;
@@ -201,7 +268,7 @@ declare const MOUNTS_MAX_STALE_MS: number;
201
268
  */
202
269
  declare function hyleRootPage(options: Configs): (props: PageProps) => Promise<ReactElement>;
203
270
  /** `export const generateMetadata = hyleRootMetadata({ ... })` with the same options as `hyleRootPage`: no metadata for a path no mount serves. */
204
- declare function hyleRootMetadata(options: Configs): (props: PageProps) => Promise<Metadata>;
271
+ declare function hyleRootMetadata(options: Configs): (props: PageProps, parent?: ResolvingMetadata) => Promise<Metadata>;
205
272
  interface HyleRootSitemapOptions {
206
273
  /** The site's public origin, for example "https://tdacorp.in": https, no path, query or credentials. */
207
274
  readonly origin: string;
@@ -210,11 +277,67 @@ interface HyleRootSitemapOptions {
210
277
  }
211
278
  /**
212
279
  * Sitemap entries for every mount of every workspace, to spread into `app/sitemap.ts`: `[...hostEntries, ...(await hyleRootSitemap(configs, { origin }))]`.
213
- * Each mount is listed with `hyleSitemap` (so `sections`, `locale`, `localePrefix` and `onIncomplete` behave as there). The mounts
280
+ * Each mount is listed with `hyleSitemap` once per locale the mount is published in (`mount.locales`, else the workspace default
281
+ * locale), so a translated page gets one entry per locale, each carrying the others as `alternates.languages` (so `sections`,
282
+ * `localePrefix` and `onIncomplete` behave as there; a configured `locale` is replaced by the one listed). The mounts
214
283
  * themselves must be readable: a failure with no last good copy throws, so a build never ships a sitemap without hyle's pages.
215
284
  */
216
285
  declare function hyleRootSitemap(options: Configs, sitemap: HyleRootSitemapOptions): Promise<MetadataRoute.Sitemap>;
217
286
 
287
+ /**
288
+ * For the host's middleware/proxy: the internal route that serves the markdown twin of `pathname`, or undefined when `pathname`
289
+ * is not one. `"/learn/x.md"` becomes `"/api/hyle/md/learn/x"`. Use it with `NextResponse.rewrite`, so the visitor's URL stays `/learn/x.md`.
290
+ */
291
+ declare function markdownRewritePath(pathname: string): string | undefined;
292
+ interface MarkdownRoute {
293
+ GET(req: Request, ctx: {
294
+ params: Promise<RouteParams>;
295
+ }): Promise<Response>;
296
+ }
297
+ /**
298
+ * `export const { GET } = createMarkdownRoute(configs)` in `app/api/hyle/md/[...path]/route.ts`, with the same configs as
299
+ * `hyleRootPage`. It serves the markdown source of a page the mounts serve (same mount matching, reserved paths, `locale`,
300
+ * `localePrefix`, fetch cache and tags as the page itself): `text/markdown; charset=utf-8` with `X-Robots-Tag: noindex`, asset links
301
+ * rewritten to the host's asset route. A redirect (301 becomes 308, 307 stays) goes to the target's `.md` twin; a list, an unknown
302
+ * path or a rejected request is 404; any other failure is 502 with no body. Reached by `markdownRewritePath` in the host's middleware.
303
+ * For a locale-prefixed site put the route under `[locale]` (`app/api/hyle/md/[locale]/[...path]/route.ts`) so `locale(params)` sees it.
304
+ */
305
+ declare function createMarkdownRoute(options: Configs): MarkdownRoute;
306
+
307
+ interface LlmsTxtOptions {
308
+ /** The site's public origin, for example "https://tdacorp.in": a bare https origin (anything else throws). */
309
+ readonly origin: string;
310
+ /** The H1. Default: the origin's host. */
311
+ readonly title?: string;
312
+ /** The summary line under the title. */
313
+ readonly description?: string;
314
+ }
315
+ /**
316
+ * `export const { GET } = createLlmsTxtRoute(configs, { origin })` in `app/llms.txt/route.ts`, with the same configs as
317
+ * `hyleRootPage`: an llms.txt index with one `## <mount name>` section per mount, listing its default-locale pages (mounts without the default locale are skipped) as
318
+ * `- [title](<origin><path>.md): description`, the links being the markdown twins `createMarkdownRoute` serves. A listing that is cut
319
+ * off keeps what was collected; a mounts or hyle failure answers 503 (never throws); Next control flow propagates.
320
+ */
321
+ declare function createLlmsTxtRoute(options: Configs, llms: LlmsTxtOptions): {
322
+ GET(): Promise<Response>;
323
+ };
324
+
325
+ interface OgImageRoute {
326
+ GET(req: Request, ctx: {
327
+ params: Promise<{
328
+ path?: string[];
329
+ }>;
330
+ }): Promise<Response>;
331
+ }
332
+ /**
333
+ * `export const { GET } = createOgImageRoute({ ...same options as hylePage })` in `app/api/hyle/og/[...path]/route.ts`.
334
+ *
335
+ * The default `og:image` of an article page when `ogImage` is unset: a plain 1200x630 card with the title and `siteName`, in the
336
+ * system font. The URL is `/api/hyle/og` + the article's canonical path (no `basePath` involved, so any mount works), resolved with the page's own resolver (a redirect, such as a renamed slug, is followed once), so cache tags and purges are the
337
+ * page's. `?locale=` is honoured only when it names a translation the article has (the path is resolved without it first), so it cannot fan out requests. An unknown path is a 404, an outage a 502.
338
+ */
339
+ declare function createOgImageRoute(options: HyleNextOptions): OgImageRoute;
340
+
218
341
  interface AssetRouteOptions {
219
342
  /** hyle's origin (HYLE_TARGET_BASE_URL). */
220
343
  readonly baseUrl: string | undefined;
@@ -259,8 +382,6 @@ declare function createAssetRoute(options: AssetRouteOptions): AssetRoute;
259
382
 
260
383
  interface HyleListProps {
261
384
  readonly options: HyleNextOptions;
262
- /** A section slug other than the mount's default ("posts"). Default: the default section. */
263
- readonly section?: string | undefined;
264
385
  /** Items to show (the server maximum is 100). Default 5. */
265
386
  readonly limit?: number | undefined;
266
387
  /** The visitor's locale. Needed under a dynamic `options.locale`, which a component cannot evaluate; else `options.locale` is used. */
@@ -270,9 +391,13 @@ interface HyleListProps {
270
391
  readonly headingLevel?: EmbedHeading | undefined;
271
392
  /** Where "View all" goes, usually the mount's index. Omit to hide it. */
272
393
  readonly moreHref?: string | undefined;
394
+ /** Start after this `next_cursor` (a malformed one is ignored). The host reads it from its own `?cursor=`. */
395
+ readonly cursor?: string | undefined;
396
+ /** Builds the "Older posts" href from the list's validated `next_cursor`; called only when there is one. Omit to hide the link. */
397
+ readonly olderHref?: ((nextCursor: string) => string) | undefined;
273
398
  }
274
399
  /** The newest articles of a section as a list or a grid of links to the mount. Slots: `list.item`, `list.empty`. */
275
- declare function HyleList({ options, section, limit, locale, layout, title, headingLevel, moreHref }: HyleListProps): Promise<ReactElement | null>;
400
+ declare function HyleList({ options, limit, locale, layout, title, headingLevel, moreHref, cursor, olderHref }: HyleListProps): Promise<ReactElement | null>;
276
401
  interface HyleArticleProps {
277
402
  readonly options: HyleNextOptions;
278
403
  /** The article's canonical site path, as hyle sends it (`canonical_path`, with the workspace prefix, no locale prefix). */
@@ -384,4 +509,4 @@ declare const ENGAGE_CSRF_HEADER = "x-hyle-engage";
384
509
  */
385
510
  declare function createEngagementRoute(options: EngagementRouteOptions): EngagementRoute;
386
511
 
387
- export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, MOUNTS_MAX_STALE_MS, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createRevalidateRoute, hyleFeed, hyleMetadata, hylePage, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap };
512
+ export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };
package/dist/next.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ReactElement } from 'react';
2
- import { H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-DL5QIZRJ.js';
3
- export { c as HyleCommentsFallback } from './embed-DL5QIZRJ.js';
4
- import { F as FetchResolverOptions, H as HyleResolver } from './resolve-DvmuBlpO.js';
5
- export { f as fetchResolver, w as workspaceTags } from './resolve-DvmuBlpO.js';
6
- import { MetadataRoute, Metadata } from 'next';
2
+ import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-DNTZ2UXv.js';
3
+ export { c as HyleCommentsFallback } from './embed-DNTZ2UXv.js';
4
+ import { F as FetchResolverOptions, H as HyleResolver } from './resolve-Ae7UFjsQ.js';
5
+ export { f as fetchResolver, w as workspaceTags } from './resolve-Ae7UFjsQ.js';
6
+ import { MetadataRoute, ResolvingMetadata, Metadata } from 'next';
7
7
  import { a as RevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.js';
8
- import './types-5D6ZD0Wi.js';
8
+ import './types-Czt887Iv.js';
9
9
 
10
10
  type RouteParams = Record<string, string | string[] | undefined>;
11
11
  interface CommonOptions {
@@ -31,6 +31,57 @@ interface CommonOptions {
31
31
  * same origin you give `hyleSitemap`.
32
32
  */
33
33
  readonly siteOrigin?: string;
34
+ /**
35
+ * The Open Graph / Twitter card image of an article. Return an absolute https URL, or a root-relative path (joined onto
36
+ * `siteOrigin`); anything invalid, or a relative path without a valid `siteOrigin`, is omitted rather than emitted broken.
37
+ * The same image becomes the BlogPosting `image`. Unset, see `ogImageRoute`.
38
+ */
39
+ readonly ogImage?: (article: ArticleRef) => OgImage | undefined;
40
+ /**
41
+ * "More in this section" under article pages (layout "article"): one extra list request of the article's section, the current
42
+ * article left out, rendered after the pager, plus the article's own child pages when it has any. `limit` is the number of
43
+ * related articles (default 5, at most 100), `title` the heading (default localized). A failed request renders nothing.
44
+ */
45
+ readonly related?: {
46
+ readonly limit?: number;
47
+ readonly title?: string;
48
+ };
49
+ /**
50
+ * Use the generated card as the article image when `ogImage` is unset and `siteOrigin` is valid: `/api/hyle/og/<canonical path>?locale=`.
51
+ * Opt-in because it needs `createOgImageRoute` mounted at `app/api/hyle/og/[...path]/route.ts`; without it the URL would 404. Default false.
52
+ */
53
+ readonly ogImageRoute?: boolean;
54
+ /**
55
+ * Where the host mounted `hyleFeed` (for example "/feed.xml", or a function of the locale). With it, article and list metadata carry
56
+ * `<link rel="alternate" type="application/rss+xml">` (absolute with `siteOrigin`; the path is not localized, so return the locale's own feed path from the function form if feeds are per-locale, which receives the page's locale and is skipped when none is configured); `hyleFeedLink` gives the same link for a host-owned page.
57
+ * `title` defaults to "<siteName> feed", else "Feed". Unset: no link.
58
+ */
59
+ readonly feed?: {
60
+ readonly path: string | ((locale: string) => string);
61
+ readonly title?: string;
62
+ };
63
+ /** Set when `createMarkdownRoute` and its middleware rewrite are mounted: article metadata then carries `<link rel="alternate" type="text/markdown">` to `<canonical>.md`. Default false. */
64
+ readonly markdownTwin?: boolean;
65
+ /** Open Graph `og:site_name`. Unset: not emitted. */
66
+ readonly siteName?: string;
67
+ /** `twitter:site` and `twitter:creator` handles (for example "@TDACorp"), emitted with the Twitter card (needs `ogImage`). Unset: not emitted. */
68
+ readonly twitter?: {
69
+ readonly site?: string;
70
+ readonly creator?: string;
71
+ };
72
+ /**
73
+ * Maps a page locale such as "en" to an Open Graph locale such as "en_US". With it, `og:locale` uses the mapped value and
74
+ * `og:locale:alternate` lists the article's other published locales (undefined results are dropped). Unset: the bare locale, no alternates.
75
+ */
76
+ readonly ogLocale?: (locale: string) => string | undefined;
77
+ /** Publisher, author and WebSite identities for the article JSON-LD graph. Needs `siteOrigin`. See `JsonLdConfig`. */
78
+ readonly jsonLd?: JsonLdConfig;
79
+ /**
80
+ * A `<title>` template such as "%s · TDACorp Learn", emitted as an absolute title (so the root layout's template does not apply
81
+ * on top) after any "Older posts" suffix. The Open Graph title and the JSON-LD headline stay the bare title. Unset: the title is as hyle gives it.
82
+ * A value without "%s" is ignored.
83
+ */
84
+ readonly titleTemplate?: string;
34
85
  readonly components?: HyleComponents;
35
86
  readonly slots?: HyleSlots;
36
87
  /**
@@ -108,35 +159,45 @@ declare function hylePage(options: HyleNextOptions): (props: PageProps) => Promi
108
159
  type HyleSitemapOptions = HyleNextOptions & {
109
160
  /** The site's public origin, for example "https://tdacorp.in": https, no path, query or credentials. */
110
161
  readonly origin: string;
111
- /** Section slugs to include besides the default section (their index must be `basePath/<slug>`). */
112
- readonly sections?: readonly string[];
113
162
  /**
114
163
  * What to do when hyle fails or a listing is cut off. `"partial"`: return what was collected. `"throw"`: throw, so a build
115
164
  * during a hyle outage fails instead of shipping a partial sitemap. Default: throw only when nothing was collected.
116
165
  */
117
166
  readonly onIncomplete?: "partial" | "throw";
167
+ /**
168
+ * The workspace default locale. Set, a translated entry's `alternates.languages` also carries `x-default` (the default-locale
169
+ * member's URL, else the entry's own), exactly as the page's hreflang does. `hyleRootSitemap` passes it from the mounts.
170
+ */
171
+ readonly defaultLocale?: string;
118
172
  };
119
173
  /**
120
174
  * Sitemap entries for the mount, to spread into the host's `app/sitemap.ts`: `[...staticEntries, ...(await hyleSitemap({ ...sameOptionsAsHylePage, origin }))]`.
121
175
  * Uses the same resolver (so the same cache and tags) as `hylePage`, and `localePrefix` for the URLs. `locale` is used only
122
176
  * when it is a string: a function of the route params is never called here, so the sitemap is for the default locale.
123
- * It pages each section index through `listPublicationPaths`, so only the default section and the listed `sections` appear,
124
- * at most 2000 pages per section; paths are percent-encoded and `lastModified` is the publish time (omitted if it is not an
125
- * ISO date). An invalid `origin` throws; see `onIncomplete` for hyle failures.
177
+ * It pages each section index through `listPublicationPaths`, so only the mount's own section appears,
178
+ * at most 2000 pages; paths are percent-encoded and `lastModified` is the later of the publish and update time (omitted if neither is an
179
+ * ISO date). A translated page carries `alternates.languages` (every locale of its group, via `localePrefix`) and the entry is for the listed `locale`; `hyleRootSitemap` lists every locale of a mount. An invalid `origin` throws; see `onIncomplete` for hyle failures.
126
180
  */
127
181
  declare function hyleSitemap(options: HyleSitemapOptions): Promise<MetadataRoute.Sitemap>;
128
182
 
183
+ /** The RSS `<link rel="alternate">` for `options.feed` in `locale` (absolute with a valid `siteOrigin`), or undefined when `feed` is unset or its function form has no locale. The path is the host's own, never locale-prefixed. For a host-owned page's own metadata. */
184
+ declare function hyleFeedLink(options: HyleNextOptions, locale?: string): {
185
+ url: string;
186
+ title: string;
187
+ } | undefined;
129
188
  /**
130
- * `export const generateMetadata = hyleMetadata({ ... })` with the same options as `hylePage`. Title, description, a canonical
131
- * URL in the page's own locale (so a fallback copy under another locale prefix points at the original), hreflang alternates
132
- * from the response's `alternates` plus `x-default` (the workspace default locale's page, else the page's own), and Open Graph. A list page canonicals to itself; with `paginate` a cursor
133
- * page canonicals to its own `?cursor=` URL (never to the first page) and its title gets an "Older posts" suffix.
134
- * Paths are relative: set `metadataBase` in the host's root layout.
189
+ * `export const generateMetadata = hyleMetadata({ ... })` with the same options as `hylePage`. Title (`titleTemplate` applied last, as an
190
+ * absolute title), description, a canonical URL in the page's own locale (so a fallback copy under another locale prefix points at the
191
+ * original), hreflang alternates from the response's `alternates` (only when the translation group has two or more published members)
192
+ * plus `x-default` (the workspace default locale's page, else the page's own), and Open Graph with the `ogImage` card (and a Twitter card
193
+ * when there is one). A list page canonicals to itself; with `paginate` a cursor page canonicals to its own `?cursor=` URL (never to the
194
+ * first page) and its title gets an "Older posts" suffix. Open Graph titles are always the bare title.
195
+ * Canonical and hreflang URLs are ABSOLUTE when `siteOrigin` is a bare https origin, else relative paths (set `metadataBase` in the host's root layout).
135
196
  * Redirects, 404s and a switched-off read surface produce no metadata; `hylePage` handles those. A 4xx rejection of the request
136
197
  * gives no metadata; any other failure (network, timeout, 5xx, 401, 403, 429) is rethrown, so a transient outage is not
137
198
  * cached as a page; Next control flow is rethrown.
138
199
  */
139
- declare function hyleMetadata(options: HyleNextOptions): (props: PageProps) => Promise<Metadata>;
200
+ declare function hyleMetadata(options: HyleNextOptions): (props: PageProps, parent?: ResolvingMetadata) => Promise<Metadata>;
140
201
 
141
202
  type HyleFeedOptions = HyleNextOptions & {
142
203
  /** Items in the feed (the server maximum is 100). Default 50. */
@@ -176,7 +237,13 @@ declare function createRevalidateRoute(options: RevalidateRouteOptions): Revalid
176
237
  */
177
238
  type HyleRootConfig = Omit<Extract<HyleNextOptions, {
178
239
  resolver?: undefined;
179
- }>, "basePath">;
240
+ }>, "basePath"> & {
241
+ /**
242
+ * Per-mount overrides keyed by the mount prefix hyle reports ("/learn", or "/" for a root mount), shallow-merged over this config
243
+ * (a given `list` or `jsonLd` replaces the config's whole value). Lets one mount carry its own `titleTemplate`, `ogImage`, `jsonLd`, `list` or `siteOrigin`.
244
+ */
245
+ readonly mountOptions?: Readonly<Record<string, Partial<Pick<CommonOptions, "titleTemplate" | "list" | "ogImage" | "jsonLd" | "siteOrigin">>>>;
246
+ };
180
247
  type Configs = HyleRootConfig | readonly HyleRootConfig[];
181
248
  /** How long a mounts copy that could not be refreshed may still be used. Past this a transient failure is rethrown. */
182
249
  declare const MOUNTS_MAX_STALE_MS: number;
@@ -201,7 +268,7 @@ declare const MOUNTS_MAX_STALE_MS: number;
201
268
  */
202
269
  declare function hyleRootPage(options: Configs): (props: PageProps) => Promise<ReactElement>;
203
270
  /** `export const generateMetadata = hyleRootMetadata({ ... })` with the same options as `hyleRootPage`: no metadata for a path no mount serves. */
204
- declare function hyleRootMetadata(options: Configs): (props: PageProps) => Promise<Metadata>;
271
+ declare function hyleRootMetadata(options: Configs): (props: PageProps, parent?: ResolvingMetadata) => Promise<Metadata>;
205
272
  interface HyleRootSitemapOptions {
206
273
  /** The site's public origin, for example "https://tdacorp.in": https, no path, query or credentials. */
207
274
  readonly origin: string;
@@ -210,11 +277,67 @@ interface HyleRootSitemapOptions {
210
277
  }
211
278
  /**
212
279
  * Sitemap entries for every mount of every workspace, to spread into `app/sitemap.ts`: `[...hostEntries, ...(await hyleRootSitemap(configs, { origin }))]`.
213
- * Each mount is listed with `hyleSitemap` (so `sections`, `locale`, `localePrefix` and `onIncomplete` behave as there). The mounts
280
+ * Each mount is listed with `hyleSitemap` once per locale the mount is published in (`mount.locales`, else the workspace default
281
+ * locale), so a translated page gets one entry per locale, each carrying the others as `alternates.languages` (so `sections`,
282
+ * `localePrefix` and `onIncomplete` behave as there; a configured `locale` is replaced by the one listed). The mounts
214
283
  * themselves must be readable: a failure with no last good copy throws, so a build never ships a sitemap without hyle's pages.
215
284
  */
216
285
  declare function hyleRootSitemap(options: Configs, sitemap: HyleRootSitemapOptions): Promise<MetadataRoute.Sitemap>;
217
286
 
287
+ /**
288
+ * For the host's middleware/proxy: the internal route that serves the markdown twin of `pathname`, or undefined when `pathname`
289
+ * is not one. `"/learn/x.md"` becomes `"/api/hyle/md/learn/x"`. Use it with `NextResponse.rewrite`, so the visitor's URL stays `/learn/x.md`.
290
+ */
291
+ declare function markdownRewritePath(pathname: string): string | undefined;
292
+ interface MarkdownRoute {
293
+ GET(req: Request, ctx: {
294
+ params: Promise<RouteParams>;
295
+ }): Promise<Response>;
296
+ }
297
+ /**
298
+ * `export const { GET } = createMarkdownRoute(configs)` in `app/api/hyle/md/[...path]/route.ts`, with the same configs as
299
+ * `hyleRootPage`. It serves the markdown source of a page the mounts serve (same mount matching, reserved paths, `locale`,
300
+ * `localePrefix`, fetch cache and tags as the page itself): `text/markdown; charset=utf-8` with `X-Robots-Tag: noindex`, asset links
301
+ * rewritten to the host's asset route. A redirect (301 becomes 308, 307 stays) goes to the target's `.md` twin; a list, an unknown
302
+ * path or a rejected request is 404; any other failure is 502 with no body. Reached by `markdownRewritePath` in the host's middleware.
303
+ * For a locale-prefixed site put the route under `[locale]` (`app/api/hyle/md/[locale]/[...path]/route.ts`) so `locale(params)` sees it.
304
+ */
305
+ declare function createMarkdownRoute(options: Configs): MarkdownRoute;
306
+
307
+ interface LlmsTxtOptions {
308
+ /** The site's public origin, for example "https://tdacorp.in": a bare https origin (anything else throws). */
309
+ readonly origin: string;
310
+ /** The H1. Default: the origin's host. */
311
+ readonly title?: string;
312
+ /** The summary line under the title. */
313
+ readonly description?: string;
314
+ }
315
+ /**
316
+ * `export const { GET } = createLlmsTxtRoute(configs, { origin })` in `app/llms.txt/route.ts`, with the same configs as
317
+ * `hyleRootPage`: an llms.txt index with one `## <mount name>` section per mount, listing its default-locale pages (mounts without the default locale are skipped) as
318
+ * `- [title](<origin><path>.md): description`, the links being the markdown twins `createMarkdownRoute` serves. A listing that is cut
319
+ * off keeps what was collected; a mounts or hyle failure answers 503 (never throws); Next control flow propagates.
320
+ */
321
+ declare function createLlmsTxtRoute(options: Configs, llms: LlmsTxtOptions): {
322
+ GET(): Promise<Response>;
323
+ };
324
+
325
+ interface OgImageRoute {
326
+ GET(req: Request, ctx: {
327
+ params: Promise<{
328
+ path?: string[];
329
+ }>;
330
+ }): Promise<Response>;
331
+ }
332
+ /**
333
+ * `export const { GET } = createOgImageRoute({ ...same options as hylePage })` in `app/api/hyle/og/[...path]/route.ts`.
334
+ *
335
+ * The default `og:image` of an article page when `ogImage` is unset: a plain 1200x630 card with the title and `siteName`, in the
336
+ * system font. The URL is `/api/hyle/og` + the article's canonical path (no `basePath` involved, so any mount works), resolved with the page's own resolver (a redirect, such as a renamed slug, is followed once), so cache tags and purges are the
337
+ * page's. `?locale=` is honoured only when it names a translation the article has (the path is resolved without it first), so it cannot fan out requests. An unknown path is a 404, an outage a 502.
338
+ */
339
+ declare function createOgImageRoute(options: HyleNextOptions): OgImageRoute;
340
+
218
341
  interface AssetRouteOptions {
219
342
  /** hyle's origin (HYLE_TARGET_BASE_URL). */
220
343
  readonly baseUrl: string | undefined;
@@ -259,8 +382,6 @@ declare function createAssetRoute(options: AssetRouteOptions): AssetRoute;
259
382
 
260
383
  interface HyleListProps {
261
384
  readonly options: HyleNextOptions;
262
- /** A section slug other than the mount's default ("posts"). Default: the default section. */
263
- readonly section?: string | undefined;
264
385
  /** Items to show (the server maximum is 100). Default 5. */
265
386
  readonly limit?: number | undefined;
266
387
  /** The visitor's locale. Needed under a dynamic `options.locale`, which a component cannot evaluate; else `options.locale` is used. */
@@ -270,9 +391,13 @@ interface HyleListProps {
270
391
  readonly headingLevel?: EmbedHeading | undefined;
271
392
  /** Where "View all" goes, usually the mount's index. Omit to hide it. */
272
393
  readonly moreHref?: string | undefined;
394
+ /** Start after this `next_cursor` (a malformed one is ignored). The host reads it from its own `?cursor=`. */
395
+ readonly cursor?: string | undefined;
396
+ /** Builds the "Older posts" href from the list's validated `next_cursor`; called only when there is one. Omit to hide the link. */
397
+ readonly olderHref?: ((nextCursor: string) => string) | undefined;
273
398
  }
274
399
  /** The newest articles of a section as a list or a grid of links to the mount. Slots: `list.item`, `list.empty`. */
275
- declare function HyleList({ options, section, limit, locale, layout, title, headingLevel, moreHref }: HyleListProps): Promise<ReactElement | null>;
400
+ declare function HyleList({ options, limit, locale, layout, title, headingLevel, moreHref, cursor, olderHref }: HyleListProps): Promise<ReactElement | null>;
276
401
  interface HyleArticleProps {
277
402
  readonly options: HyleNextOptions;
278
403
  /** The article's canonical site path, as hyle sends it (`canonical_path`, with the workspace prefix, no locale prefix). */
@@ -384,4 +509,4 @@ declare const ENGAGE_CSRF_HEADER = "x-hyle-engage";
384
509
  */
385
510
  declare function createEngagementRoute(options: EngagementRouteOptions): EngagementRoute;
386
511
 
387
- export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, MOUNTS_MAX_STALE_MS, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createRevalidateRoute, hyleFeed, hyleMetadata, hylePage, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap };
512
+ export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };