@justanarthur/payload-www 0.3.4 → 1.0.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.
Files changed (62) hide show
  1. package/README.md +317 -307
  2. package/dist/access.d.ts +2 -2
  3. package/dist/access.js +6 -30
  4. package/dist/blocks.d.ts +0 -10
  5. package/dist/blocks.js +8 -33
  6. package/dist/collections.d.ts +33 -225
  7. package/dist/collections.js +186 -661
  8. package/dist/config.d.ts +19 -105
  9. package/dist/config.js +263 -868
  10. package/dist/fields.d.ts +4 -46
  11. package/dist/fields.js +183 -73
  12. package/dist/imagehash.js +0 -15
  13. package/dist/import-map-provider.d.ts +0 -16
  14. package/dist/import-map-provider.js +0 -15
  15. package/dist/metadata.d.ts +24 -89
  16. package/dist/metadata.js +123 -258
  17. package/dist/pages.d.ts +37 -319
  18. package/dist/pages.js +355 -973
  19. package/dist/render-pages.d.ts +69 -564
  20. package/dist/render-pages.js +476 -1502
  21. package/dist/sitemap.d.ts +10 -0
  22. package/dist/sitemap.js +324 -0
  23. package/dist/translator.js +0 -15
  24. package/dist/utils.d.ts +4 -12
  25. package/dist/utils.js +10 -56
  26. package/package.json +75 -178
  27. package/dist/components.d.ts +0 -6
  28. package/dist/components.js +0 -39
  29. package/dist/core-access.d.ts +0 -11
  30. package/dist/core-access.js +0 -44
  31. package/dist/core-blocks.d.ts +0 -24
  32. package/dist/core-blocks.js +0 -89
  33. package/dist/core-fields.d.ts +0 -73
  34. package/dist/core-fields.js +0 -181
  35. package/dist/core-utils.d.ts +0 -16
  36. package/dist/core-utils.js +0 -73
  37. package/dist/data-collections.d.ts +0 -229
  38. package/dist/data-collections.js +0 -697
  39. package/dist/data-seed.d.ts +0 -76
  40. package/dist/data-seed.js +0 -212
  41. package/dist/data-test.d.ts +0 -30
  42. package/dist/data-test.js +0 -1134
  43. package/dist/globals.d.ts +0 -69
  44. package/dist/globals.js +0 -259
  45. package/dist/hooks.d.ts +0 -108
  46. package/dist/hooks.js +0 -228
  47. package/dist/index.d.ts +0 -6
  48. package/dist/index.js +0 -39
  49. package/dist/render-components.d.ts +0 -42
  50. package/dist/render-components.js +0 -154
  51. package/dist/render-metadata.d.ts +0 -122
  52. package/dist/render-metadata.js +0 -393
  53. package/dist/render-utils.d.ts +0 -166
  54. package/dist/render-utils.js +0 -401
  55. package/dist/seed.d.ts +0 -76
  56. package/dist/seed.js +0 -212
  57. package/dist/server.d.ts +0 -980
  58. package/dist/server.js +0 -2265
  59. package/dist/test.d.ts +0 -30
  60. package/dist/test.js +0 -1134
  61. package/dist/with-www-config.d.ts +0 -108
  62. package/dist/with-www-config.js +0 -1030
@@ -1,393 +0,0 @@
1
-
2
- var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true,
12
- configurable: true,
13
- set: __exportSetter.bind(all, name)
14
- });
15
- };
16
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
-
18
- // src/render/metadata/jsonld.ts
19
- function getImageUrl(doc, siteUrl) {
20
- const img = doc?.meta?.image ?? doc?.heroImage ?? doc?.image;
21
- if (!img)
22
- return null;
23
- if (typeof img === "string")
24
- return img;
25
- if (img?.url)
26
- return img.url.startsWith("http") ? img.url : `${siteUrl}${img.url}`;
27
- return null;
28
- }
29
- function getImageUrlWithLog(doc, siteUrl) {
30
- const result = getImageUrl(doc, siteUrl);
31
- console.log("[WWW] render/metadata:jsonld:getImageUrl ->", result);
32
- return result;
33
- }
34
- function resolveLocalizedField(value, locale) {
35
- if (value == null)
36
- return "";
37
- if (typeof value === "string") {
38
- if (!value.startsWith("{"))
39
- return value;
40
- try {
41
- const parsed = JSON.parse(value);
42
- return resolveLocalizedField(parsed, locale);
43
- } catch {
44
- return value;
45
- }
46
- }
47
- if (typeof value !== "object")
48
- return "";
49
- const obj = value;
50
- if (typeof obj[locale] === "string" && obj[locale].length > 0) {
51
- return obj[locale];
52
- }
53
- return Object.values(obj).filter((v) => typeof v === "string" && v.length > 0).join(" / ");
54
- }
55
- function resolveLocalizedFieldWithLog(value, locale) {
56
- const result = resolveLocalizedField(value, locale);
57
- if (value && typeof value === "object") {
58
- console.log("[WWW] render/metadata:jsonld:resolveLocalizedField locale=", locale, "->", JSON.stringify(result));
59
- }
60
- return result;
61
- }
62
- function buildArticleLd({
63
- doc,
64
- url,
65
- locale,
66
- siteUrl,
67
- type = "BlogPosting",
68
- publisherName,
69
- publisherLogo
70
- }) {
71
- const name = publisherName ?? new URL(siteUrl).hostname;
72
- console.log("[WWW] render/metadata:buildArticleLd url=", url, "locale=", locale, "type=", type, "publisherName=", name);
73
- const ld = {
74
- "@context": "https://schema.org",
75
- "@type": type,
76
- "@id": `${url}#article`,
77
- headline: resolveLocalizedFieldWithLog(doc.title, locale),
78
- description: resolveLocalizedFieldWithLog(doc.meta?.description ?? doc.description ?? doc.excerpt, locale),
79
- inLanguage: locale,
80
- url,
81
- dateModified: doc.updatedAt ? new Date(doc.updatedAt).toISOString() : undefined
82
- };
83
- const datePublished = doc.publishedAt ?? doc.createdAt;
84
- if (datePublished)
85
- ld.datePublished = new Date(datePublished).toISOString();
86
- const imgUrl = getImageUrlWithLog(doc, siteUrl);
87
- if (imgUrl)
88
- ld.image = imgUrl;
89
- ld.author = { "@type": "Organization", name, url: siteUrl };
90
- const publisher = { "@type": "Organization", name };
91
- if (publisherLogo !== undefined) {
92
- if (publisherLogo !== null)
93
- publisher.logo = { "@type": "ImageObject", url: publisherLogo };
94
- }
95
- ld.publisher = publisher;
96
- return ld;
97
- }
98
- function buildBreadcrumbsLd({
99
- items,
100
- currentUrl
101
- }) {
102
- console.log("[WWW] render/metadata:buildBreadcrumbsLd items=", items.length, "currentUrl=", currentUrl);
103
- return {
104
- "@context": "https://schema.org",
105
- "@type": "BreadcrumbList",
106
- itemListElement: items.map((item, index) => ({
107
- "@type": "ListItem",
108
- position: index + 1,
109
- name: item.label,
110
- item: index === items.length - 1 ? currentUrl : item.url
111
- }))
112
- };
113
- }
114
- function buildOrganizationLd({
115
- siteUrl,
116
- name,
117
- logo,
118
- sameAs
119
- }) {
120
- console.log("[WWW] render/metadata:buildOrganizationLd siteUrl=", siteUrl, "name=", name, "logo?", Boolean(logo), "sameAs?", Boolean(sameAs));
121
- const org = {
122
- "@context": "https://schema.org",
123
- "@type": "Organization",
124
- "@id": `${siteUrl}#organization`,
125
- url: siteUrl,
126
- ...name && { name },
127
- ...logo && { logo: { "@type": "ImageObject", url: logo } },
128
- ...sameAs && sameAs.length > 0 && { sameAs }
129
- };
130
- return org;
131
- }
132
-
133
- // src/render/metadata/hreflang.ts
134
- async function buildHreflangAlternates({
135
- siteUrl,
136
- locale,
137
- urlPrefix,
138
- storedSlug,
139
- queryAllLocaleSlugs,
140
- nested,
141
- homeSlug,
142
- defaultLocale,
143
- locales,
144
- localePrefix = "always"
145
- }) {
146
- const allLocaleSlugs = await queryAllLocaleSlugs(storedSlug, locale);
147
- console.log("[WWW] render/metadata:buildHreflangAlternates storedSlug=", storedSlug, "locale=", locale, "allLocaleSlugs=", JSON.stringify(allLocaleSlugs));
148
- const languages = {};
149
- const urlFor = (l, slug) => {
150
- const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
151
- const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
152
- const urlPath = slug === homeSlug ? "/" : nested ? "/" + slug.replaceAll("_", "/") : "/" + slug;
153
- const localeSegment = localePrefix === "never" ? "" : localePrefix === "as-needed" && l === defaultLocale ? "" : `/${l}`;
154
- return `${siteUrl}${localeSegment}${prefixSegment}${urlPath}`;
155
- };
156
- for (const l of locales) {
157
- const slugForLocale = allLocaleSlugs?.[l];
158
- if (!slugForLocale)
159
- continue;
160
- languages[l] = urlFor(l, slugForLocale);
161
- }
162
- if (allLocaleSlugs?.[defaultLocale]) {
163
- languages["x-default"] = urlFor(defaultLocale, allLocaleSlugs[defaultLocale]);
164
- }
165
- console.log("[WWW] render/metadata:buildHreflangAlternates ->", JSON.stringify(languages));
166
- return languages;
167
- }
168
-
169
- // src/render/metadata/slug.ts
170
- var SLUG_NESTED_DIVIDER = "_";
171
- function segmentsToStoredSlug(segments, nested) {
172
- if (!Array.isArray(segments)) {
173
- console.log("[WWW] render/metadata:segmentsToStoredSlug string passthrough:", JSON.stringify(segments));
174
- return segments;
175
- }
176
- const result = nested ? segments.join(SLUG_NESTED_DIVIDER) : segments[0] ?? "";
177
- console.log("[WWW] render/metadata:segmentsToStoredSlug nested=", nested, "segments=", JSON.stringify(segments), "->", result);
178
- return result;
179
- }
180
- function segmentsToUrlPath(segments, nested) {
181
- let result;
182
- if (!Array.isArray(segments))
183
- result = "/" + segments;
184
- else if (nested)
185
- result = "/" + segments.join("/");
186
- else
187
- result = "/" + (segments[0] ?? "");
188
- console.log("[WWW] render/metadata:segmentsToUrlPath nested=", nested, "segments=", JSON.stringify(segments), "->", result);
189
- return result;
190
- }
191
- function storedSlugToSegments(storedSlug, nested) {
192
- const result = nested ? storedSlug.split(SLUG_NESTED_DIVIDER) : storedSlug;
193
- console.log("[WWW] render/metadata:storedSlugToSegments nested=", nested, "storedSlug=", storedSlug, "->", JSON.stringify(result));
194
- return result;
195
- }
196
- function buildCanonicalUrl({
197
- siteUrl,
198
- locale,
199
- urlPrefix,
200
- urlPath
201
- }) {
202
- const trimmedPrefix = urlPrefix.replace(/^\/|\/$/g, "");
203
- const prefixSegment = trimmedPrefix ? `/${trimmedPrefix}` : "";
204
- const result = `${siteUrl}/${locale}${prefixSegment}${urlPath}`;
205
- console.log("[WWW] render/metadata:buildCanonicalUrl siteUrl=", siteUrl, "locale=", locale, "urlPrefix=", urlPrefix, "urlPath=", urlPath, "->", result);
206
- return result;
207
- }
208
- function getUrlPath(segments, nested, homeSlug) {
209
- const urlPath = segmentsToUrlPath(segments, nested);
210
- if (nested && !Array.isArray(segments)) {
211
- if (segments === homeSlug)
212
- return "/";
213
- } else if (nested && Array.isArray(segments)) {
214
- const stored = segments.join(SLUG_NESTED_DIVIDER);
215
- if (stored === homeSlug)
216
- return "/";
217
- }
218
- return urlPath;
219
- }
220
-
221
- // src/render/metadata/query.ts
222
- import { getPayload } from "payload";
223
- import { cache } from "react";
224
-
225
- // src/core/utils/getFromImportMap.ts
226
- function getFromImportMap(key, importMap) {
227
- const resolvedKey = key.includes("#") ? key : key + "#default";
228
- const value = importMap[resolvedKey];
229
- console.log("[WWW] core/utils:getFromImportMap key=", key, "resolved=", resolvedKey, "hit=", Boolean(value));
230
- return value;
231
- }
232
-
233
- // src/render/metadata/query.ts
234
- var queryDocBySlug = cache(async function queryDocBySlug2({
235
- collectionSlug,
236
- slug,
237
- slugField = "slug",
238
- locale,
239
- draft = false,
240
- config
241
- }) {
242
- console.log("[WWW] render/metadata:queryDocBySlug collection=", collectionSlug, "slug=", slug, "slugField=", slugField, "locale=", locale, "draft=", draft);
243
- const payload = await getPayload({ config });
244
- const result = await payload.find({
245
- collection: collectionSlug,
246
- draft,
247
- limit: 1,
248
- pagination: false,
249
- overrideAccess: draft,
250
- where: { [slugField]: { equals: slug } },
251
- locale
252
- });
253
- const doc = result.docs?.[0] ?? null;
254
- console.log("[WWW] render/metadata:queryDocBySlug ->", doc ? "hit" : "miss");
255
- return doc;
256
- });
257
- var queryAllDocs = cache(async function queryAllDocs2({
258
- collectionSlug,
259
- slugField = "slug",
260
- locale,
261
- config
262
- }) {
263
- console.log("[WWW] render/metadata:queryAllDocs collection=", collectionSlug, "locale=", locale);
264
- const payload = await getPayload({ config });
265
- const result = await payload.find({
266
- collection: collectionSlug,
267
- draft: false,
268
- limit: 1000,
269
- pagination: false,
270
- overrideAccess: false,
271
- select: { [slugField]: true },
272
- locale
273
- });
274
- const docs = result.docs ?? [];
275
- console.log("[WWW] render/metadata:queryAllDocs -> count=", docs.length);
276
- return docs;
277
- });
278
- var queryAllLocaleSlugs = cache(async function queryAllLocaleSlugs2({
279
- collectionSlug,
280
- slug,
281
- slugField = "slug",
282
- locale,
283
- config
284
- }) {
285
- console.log("[WWW] render/metadata:queryAllLocaleSlugs collection=", collectionSlug, "slug=", slug, "locale=", locale);
286
- const payload = await getPayload({ config });
287
- const result = await payload.find({
288
- collection: collectionSlug,
289
- draft: false,
290
- limit: 1,
291
- pagination: false,
292
- overrideAccess: false,
293
- locale,
294
- where: { [slugField]: { equals: slug } },
295
- select: { [slugField]: true }
296
- });
297
- const doc = result.docs?.[0];
298
- if (!doc) {
299
- console.log("[WWW] render/metadata:queryAllLocaleSlugs -> undefined (no doc)");
300
- return;
301
- }
302
- let fieldValue = doc[slugField];
303
- if (doc.id != null) {
304
- const allLocales = await payload.findByID({
305
- collection: collectionSlug,
306
- id: doc.id,
307
- locale: "all",
308
- draft: false,
309
- overrideAccess: false,
310
- select: { [slugField]: true }
311
- }).catch(() => null);
312
- if (allLocales)
313
- fieldValue = allLocales[slugField];
314
- }
315
- if (fieldValue && typeof fieldValue === "object") {
316
- console.log("[WWW] render/metadata:queryAllLocaleSlugs -> localized map=", JSON.stringify(fieldValue));
317
- return fieldValue;
318
- }
319
- const resolved = await config;
320
- const rawLocales = Array.isArray(resolved?.localization?.localeCodes) ? resolved.localization.localeCodes : resolved?.localization?.locales?.map((l) => l.code) ?? [];
321
- const out = {};
322
- for (const l of rawLocales)
323
- out[l] = String(fieldValue ?? slug);
324
- console.log("[WWW] render/metadata:queryAllLocaleSlugs -> flat-fanout locales=", rawLocales.length, "slug=", JSON.stringify(fieldValue ?? slug));
325
- return out;
326
- });
327
- var queryGlobal = cache(async function queryGlobal2({
328
- globalSlug,
329
- locale,
330
- depth = 0,
331
- draft = false,
332
- config
333
- }) {
334
- console.log("[WWW] render/metadata:queryGlobal global=", globalSlug, "locale=", locale, "depth=", depth, "draft=", draft);
335
- const payload = await getPayload({ config });
336
- try {
337
- const global = await payload.findGlobal({
338
- slug: globalSlug,
339
- depth,
340
- draft,
341
- locale
342
- });
343
- console.log("[WWW] render/metadata:queryGlobal -> hit");
344
- return global;
345
- } catch (error) {
346
- console.warn("[WWW] render/metadata:queryGlobal failed for slug=", globalSlug, "err=", String(error));
347
- return null;
348
- }
349
- });
350
- function getRenderModuleExports(exportName, collection, importMap) {
351
- const path = collection?.custom?.path;
352
- if (!path) {
353
- console.log("[WWW] render/metadata:getRenderModuleExports no custom.path exportName=", exportName);
354
- return;
355
- }
356
- const mod = getFromImportMap(path, importMap);
357
- const value = mod?.[exportName];
358
- console.log("[WWW] render/metadata:getRenderModuleExports exportName=", exportName, "path=", path, "hit=", Boolean(value));
359
- return value;
360
- }
361
-
362
- // src/exports/render-metadata.ts
363
- var render_metadata_default = {
364
- buildArticleLd,
365
- buildBreadcrumbsLd,
366
- buildOrganizationLd,
367
- buildHreflangAlternates,
368
- queryDocBySlug,
369
- queryAllDocs,
370
- queryAllLocaleSlugs,
371
- getUrlPath,
372
- segmentsToStoredSlug,
373
- segmentsToUrlPath,
374
- storedSlugToSegments,
375
- buildCanonicalUrl,
376
- getRenderModuleExports
377
- };
378
- export {
379
- storedSlugToSegments,
380
- segmentsToUrlPath,
381
- segmentsToStoredSlug,
382
- queryDocBySlug,
383
- queryAllLocaleSlugs,
384
- queryAllDocs,
385
- getUrlPath,
386
- getRenderModuleExports,
387
- render_metadata_default as default,
388
- buildOrganizationLd,
389
- buildHreflangAlternates,
390
- buildCanonicalUrl,
391
- buildBreadcrumbsLd,
392
- buildArticleLd
393
- };
@@ -1,166 +0,0 @@
1
- type CreatePreviewHandlerOptions = {
2
- /** Resolves the host's site URL (used to construct preview links if
3
- * the host navigates back to the canonical site). */
4
- getServerSideURL: () => string;
5
- /**
6
- * Secret token the host configures in `process.env.PREVIEW_SECRET`.
7
- * The handler validates `?previewSecret=...` against this value and
8
- * 401s on mismatch.
9
- */
10
- secret: string;
11
- /**
12
- * Whether to enable draft mode on a valid preview. Hosts that use
13
- * their own preview mechanism can pass `false`.
14
- * Default: `true`.
15
- */
16
- enableDraftMode?: boolean;
17
- };
18
- /**
19
- * Build a Next.js `GET` route handler for the host's
20
- * `app/(payload)/next/preview/route.ts`. Validates the preview secret
21
- * from the query string, enables draft mode if configured, and
22
- * redirects to the `?path=...` value.
23
- *
24
- * Usage:
25
- *
26
- * // app/(payload)/next/preview/route.ts
27
- * import { createPreviewHandler } from '@justanarthur/payload-www/render-utils'
28
- * import { getServerSideURL } from '@/utilities/getURL'
29
- * const GET = createPreviewHandler({
30
- * getServerSideURL,
31
- * secret: process.env.PREVIEW_SECRET || ''
32
- * })
33
- */
34
- declare function createPreviewHandler(options: CreatePreviewHandlerOptions): (req: Request) => Promise<Response>;
35
- import { MetadataRoute } from "next";
36
- type CreateSitemapFileOptions = {
37
- /**
38
- * Collection slugs whose docs should appear in the sitemap. Each
39
- * collection must have a `slug` field on its documents. The lib
40
- * emits a single unified sitemap at `/sitemap.xml` listing every
41
- * doc from every configured collection across every active locale.
42
- */
43
- collections: string[];
44
- /**
45
- * The Payload config promise. The factory resolves it at request
46
- * time.
47
- */
48
- config: Promise<any>;
49
- /**
50
- * The host's site URL — used to build absolute URLs.
51
- */
52
- getServerSideURL: () => string;
53
- /**
54
- * Locale prefix mode. Mirrors next-intl's `localePrefix` so the
55
- * sitemap URLs match the host's actual route shape:
56
- *
57
- * - `'always'`: every URL is prefixed with `/{locale}/…`
58
- * (e.g. `/en/about`, `/uk/about`). The default.
59
- * - `'as-needed'`: the default locale renders without a prefix
60
- * (e.g. `/about`), other locales are prefixed (`/uk/about`).
61
- * - `'never'`: no locale prefix (only useful for single-locale
62
- * sites or hosts that don't expose locales in the URL).
63
- *
64
- * The default locale is read from `config.localization.defaultLocale`
65
- * — the same single source of truth that next-intl and the rest of
66
- * the lib use.
67
- */
68
- localePrefix?: "always" | "as-needed" | "never";
69
- /**
70
- * Optional filter for which locales to include in the sitemap.
71
- * Defaults to every locale declared in `config.localization.locales`.
72
- */
73
- locales?: string[];
74
- /**
75
- * Optional URL path prefix per collection. The Pages collection
76
- * lives at the root (`/about`) so it doesn't need a prefix, but
77
- * collections mounted under a sub-route (e.g. a posts collection
78
- * under `/posts/[...slug]`) need their URLs prefixed with `/posts`
79
- * so the sitemap entries match the actual route.
80
- *
81
- * Defaults to `''` (no prefix). Pass a value like `'/posts'`
82
- * (leading slash, no trailing slash) for a sub-routed collection.
83
- */
84
- urlPrefixes?: Record<string, string>;
85
- /**
86
- * Optional priority / changeFrequency overrides per collection.
87
- */
88
- perCollection?: Record<string, {
89
- priority?: number;
90
- changefreq?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
91
- }>;
92
- /**
93
- * Per-collection nested-slug flag. When a collection is marked
94
- * `true`, its stored `about_us` slug is expanded into the
95
- * `/about/us` URL path (and hreflang alternates), matching a
96
- * `createCollectionPageExports({ nested: true })` route. Defaults
97
- * to `false` (flat slugs) for every collection.
98
- */
99
- nested?: Record<string, boolean>;
100
- };
101
- /**
102
- * A Next.js sitemap function for the host's
103
- * `app/(frontend)/sitemap.ts`. Returns the typed
104
- * `MetadataRoute.Sitemap` array — Next.js handles XML serialization.
105
- *
106
- * Usage — single unified sitemap:
107
- *
108
- * // app/(frontend)/sitemap.ts
109
- * import { createSitemapFile } from '@justanarthur/payload-www/render-utils'
110
- * import configPromise from '@payload-config'
111
- * import { getServerSideURL } from '@/utilities/getURL'
112
- *
113
- * createSitemapFile({
114
- * collections: ['pages', 'posts'],
115
- * config: configPromise,
116
- * getServerSideURL,
117
- * localePrefix: 'as-needed',
118
- * urlPrefixes: { posts: '/posts' }
119
- * })
120
- *
121
- * The lib resolves the sitemap at request time, queries every
122
- * configured collection across every active locale, and emits one
123
- * unified `<urlset>` with full `alternates.languages` hreflang blocks
124
- * per URL. Google accepts up to 50,000 URLs per file.
125
- */
126
- type SitemapFunction = () => Promise<MetadataRoute.Sitemap>;
127
- declare function createSitemapFile(options: CreateSitemapFileOptions): SitemapFunction;
128
- import { ReactElement } from "react";
129
- /**
130
- * Hreflang alternate URLs as a `lang → url` map. Always includes an
131
- * `'x-default'` entry pointing at the default locale's URL.
132
- */
133
- type HreflangAlternates = Record<string, string>;
134
- type LocaleSwitcherProps = {
135
- /**
136
- * The currently-active locale (the one being rendered). The
137
- * switcher marks the corresponding link with `aria-current="true"`.
138
- */
139
- currentLocale: string;
140
- /**
141
- * The hreflang alternates map as returned by the lib's metadata
142
- * pipeline. Keys are locale codes; values are absolute URLs. An
143
- * `'x-default'` entry is also expected.
144
- */
145
- hreflangAlternates: HreflangAlternates;
146
- /**
147
- * Optional human-readable labels per locale. When missing, the
148
- * switcher falls back to uppercased locale codes.
149
- */
150
- labels?: Record<string, string>;
151
- };
152
- /**
153
- * Render a list of links to the same page in every other locale.
154
- * The component is server-renderable (no `'use client'`) and emits
155
- * a single `<nav>` element with one `<a>` per locale plus an
156
- * `x-default` fallback. The lib's `<PageShowcase>` mounts it as a
157
- * child of the sidebar; hosts can also drop it elsewhere on the
158
- * page.
159
- */
160
- declare function LocaleSwitcher({ currentLocale, hreflangAlternates, labels }: LocaleSwitcherProps): ReactElement;
161
- declare const _default: {
162
- createPreviewHandler: typeof createPreviewHandler;
163
- createSitemapFile: typeof createSitemapFile;
164
- LocaleSwitcher: typeof LocaleSwitcher;
165
- };
166
- export { _default as default, createSitemapFile, createPreviewHandler, SitemapFunction, LocaleSwitcherProps, LocaleSwitcher, CreateSitemapFileOptions, CreatePreviewHandlerOptions };