@justanarthur/payload-www 0.1.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 +381 -0
  2. package/dist/access.d.ts +11 -0
  3. package/dist/access.js +34 -0
  4. package/dist/blocks.d.ts +24 -0
  5. package/dist/blocks.js +75 -0
  6. package/dist/collections.d.ts +200 -0
  7. package/dist/collections.js +625 -0
  8. package/dist/components.d.ts +6 -0
  9. package/dist/components.js +38 -0
  10. package/dist/config.d.ts +100 -0
  11. package/dist/config.js +914 -0
  12. package/dist/core-access.d.ts +11 -0
  13. package/dist/core-access.js +34 -0
  14. package/dist/core-blocks.d.ts +24 -0
  15. package/dist/core-blocks.js +75 -0
  16. package/dist/core-fields.d.ts +36 -0
  17. package/dist/core-fields.js +134 -0
  18. package/dist/core-utils.d.ts +16 -0
  19. package/dist/core-utils.js +59 -0
  20. package/dist/data-collections.d.ts +200 -0
  21. package/dist/data-collections.js +625 -0
  22. package/dist/data-seed.d.ts +76 -0
  23. package/dist/data-seed.js +212 -0
  24. package/dist/data-test.d.ts +30 -0
  25. package/dist/data-test.js +1018 -0
  26. package/dist/fields.d.ts +36 -0
  27. package/dist/fields.js +134 -0
  28. package/dist/globals.d.ts +48 -0
  29. package/dist/globals.js +228 -0
  30. package/dist/hooks.d.ts +108 -0
  31. package/dist/hooks.js +196 -0
  32. package/dist/imagehash.d.ts +3 -0
  33. package/dist/imagehash.js +24 -0
  34. package/dist/import-map-provider.d.ts +20 -0
  35. package/dist/import-map-provider.js +26 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +38 -0
  38. package/dist/metadata.d.ts +122 -0
  39. package/dist/metadata.js +335 -0
  40. package/dist/pages.d.ts +323 -0
  41. package/dist/pages.js +1016 -0
  42. package/dist/render-components.d.ts +42 -0
  43. package/dist/render-components.js +144 -0
  44. package/dist/render-metadata.d.ts +122 -0
  45. package/dist/render-metadata.js +335 -0
  46. package/dist/render-pages.d.ts +574 -0
  47. package/dist/render-pages.js +1450 -0
  48. package/dist/render-utils.d.ts +158 -0
  49. package/dist/render-utils.js +341 -0
  50. package/dist/seed.d.ts +76 -0
  51. package/dist/seed.js +212 -0
  52. package/dist/server.d.ts +922 -0
  53. package/dist/server.js +2055 -0
  54. package/dist/test.d.ts +30 -0
  55. package/dist/test.js +1018 -0
  56. package/dist/translator.d.ts +2 -0
  57. package/dist/translator.js +24 -0
  58. package/dist/utils.d.ts +16 -0
  59. package/dist/utils.js +59 -0
  60. package/dist/with-www-config.d.ts +100 -0
  61. package/dist/with-www-config.js +914 -0
  62. package/package.json +246 -0
@@ -0,0 +1,100 @@
1
+ import { Block as Block3, CollectionConfig as CollectionConfig4, Config, GlobalConfig as GlobalConfig3, Plugin } from "payload";
2
+ /**
3
+ * Minimal next-intl routing contract the lib reads. Hosts pass
4
+ * their `defineRouting({...})` result directly; the lib only needs
5
+ * the shape below.
6
+ *
7
+ * `localePrefix` accepts either the simple string form
8
+ * (`'always' | 'as-needed' | 'never'`) or next-intl's verbose
9
+ * `LocalePrefixConfigVerbose` shape (`{ mode, prefixes? }`). The lib
10
+ * normalizes both to a string `mode` internally.
11
+ */
12
+ type LocalePrefixValue = "always" | "as-needed" | "never" | {
13
+ mode?: "always" | "as-needed" | "never";
14
+ };
15
+ type PageRouting = {
16
+ locales: readonly string[];
17
+ defaultLocale: string;
18
+ localePrefix?: LocalePrefixValue;
19
+ /** Optional human-readable labels per locale (used by the
20
+ * `<LocaleSwitcher>`). Falls back to the locale code when missing.
21
+ * Not part of next-intl's `defineRouting` shape — the host extends
22
+ * its routing object to include it (e.g. via a type assertion). */
23
+ labels?: Record<string, string>;
24
+ };
25
+ type WWWConfigOptions = {
26
+ /**
27
+ * Locales the host uses. First entry is the default locale
28
+ * (used for translation source-of-truth and the home-page path).
29
+ * The list drives hreflang alternates, sitemap, and the per-locale
30
+ * revalidation tag suffix.
31
+ */
32
+ locales: string[];
33
+ /**
34
+ * The host's next-intl routing config (the value returned from
35
+ * `defineRouting({...})`). When passed, `locales`, `defaultLocale`,
36
+ * and `localePrefix` are read from this object instead of the
37
+ * legacy `locales: string[]` field. `localePrefix` is normalized
38
+ * to the simple string form internally — next-intl's verbose
39
+ * `{ mode, prefixes? }` shape is accepted and reduced to `mode`.
40
+ */
41
+ routing?: PageRouting;
42
+ /**
43
+ * Blocks the Pages collection accepts.
44
+ */
45
+ blocks: Block3[];
46
+ /**
47
+ * Collection slugs the Header / Footer nav `link` fields can
48
+ * reference. Defaults to `['pages']` (the lib's Pages collection).
49
+ * Pass a different list when your host has additional linkable
50
+ * collections.
51
+ */
52
+ linkRelationTo?: string[];
53
+ /**
54
+ * Register the lib's Posts collection. Default: `true`. The
55
+ * translator plugin's default `collections` list is
56
+ * `['pages', 'posts']`; pass `false` here to opt out and either
57
+ * define your own posts-like collection or drop the translator.
58
+ */
59
+ registerPosts?: boolean;
60
+ /**
61
+ * Final say on the lib's default plugin list. Receives the
62
+ * `[seoPlugin, imageHashPlugin, translator]` array; return the
63
+ * list to apply. Common uses: drop the translator (no AI
64
+ * translation in this project), add a second `seoPlugin({...})`
65
+ * call for posts, or layer on a `formBuilderPlugin(...)`.
66
+ */
67
+ defaultPlugins?: (defaults: Plugin[]) => Plugin[];
68
+ };
69
+ type WWWConfigApi = {
70
+ withWWWConfig: (config: WWWInputConfig) => Promise<Config> | Config;
71
+ };
72
+ type WWWInputConfig = Omit<Config, "collections" | "globals"> & {
73
+ collections: ((args: {
74
+ defaultCollections: CollectionConfig4[];
75
+ }) => CollectionConfig4[]) | CollectionConfig4[];
76
+ globals: ((args: {
77
+ defaultGlobals: GlobalConfig3[];
78
+ }) => GlobalConfig3[]) | GlobalConfig3[];
79
+ };
80
+ /**
81
+ * Build the lib's data-config API surface, configured for a specific host.
82
+ *
83
+ * Hosts call this once with their `locales` and `blocks`; the returned
84
+ * object is **safe to import from a Node entrypoint** such as
85
+ * `payload.config.ts` — it only contains Payload collection / global
86
+ * factories and the `withWWWConfig` composer.
87
+ *
88
+ * The lib applies three plugins by default: `seoPlugin` (Pages + meta tab),
89
+ * `imageHashPlugin` (Blurhash/Thumbhash on uploads), and `translator`
90
+ * (auto-translation workflow). Use the `defaultPlugins` callback to
91
+ * drop or extend the list.
92
+ *
93
+ * For the App Router rendering side, import from the lib's render
94
+ * subpaths:
95
+ *
96
+ * import { createCollectionPageExports } from '@justanarthur/payload-www/render-pages'
97
+ * import { createPreviewHandler, createSitemapFile } from '@justanarthur/payload-www/render-utils'
98
+ */
99
+ declare function createWWWConfig(options: WWWConfigOptions): WWWConfigApi;
100
+ export { createWWWConfig as default, createWWWConfig, WWWInputConfig, WWWConfigOptions, WWWConfigApi };