@justanarthur/payload-www 0.3.5 → 1.2.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 (63) hide show
  1. package/README.md +317 -307
  2. package/dist/access.d.ts +2 -2
  3. package/dist/access.js +3 -17
  4. package/dist/blocks.d.ts +7 -12
  5. package/dist/blocks.js +24 -43
  6. package/dist/cli.js +201 -0
  7. package/dist/collections.d.ts +33 -225
  8. package/dist/collections.js +185 -639
  9. package/dist/config.d.ts +19 -105
  10. package/dist/config.js +257 -855
  11. package/dist/fields.d.ts +4 -46
  12. package/dist/fields.js +177 -53
  13. package/dist/imagehash.js +0 -15
  14. package/dist/import-map-provider.d.ts +0 -16
  15. package/dist/import-map-provider.js +0 -15
  16. package/dist/metadata.d.ts +24 -89
  17. package/dist/metadata.js +123 -255
  18. package/dist/pages.d.ts +37 -319
  19. package/dist/pages.js +349 -964
  20. package/dist/render-pages.d.ts +70 -565
  21. package/dist/render-pages.js +464 -1477
  22. package/dist/sitemap.d.ts +10 -0
  23. package/dist/sitemap.js +337 -0
  24. package/dist/translator.js +0 -15
  25. package/dist/utils.d.ts +10 -12
  26. package/dist/utils.js +18 -41
  27. package/package.json +81 -178
  28. package/dist/components.d.ts +0 -6
  29. package/dist/components.js +0 -39
  30. package/dist/core-access.d.ts +0 -11
  31. package/dist/core-access.js +0 -34
  32. package/dist/core-blocks.d.ts +0 -24
  33. package/dist/core-blocks.js +0 -79
  34. package/dist/core-fields.d.ts +0 -73
  35. package/dist/core-fields.js +0 -167
  36. package/dist/core-utils.d.ts +0 -16
  37. package/dist/core-utils.js +0 -63
  38. package/dist/data-collections.d.ts +0 -229
  39. package/dist/data-collections.js +0 -676
  40. package/dist/data-seed.d.ts +0 -76
  41. package/dist/data-seed.js +0 -212
  42. package/dist/data-test.d.ts +0 -30
  43. package/dist/data-test.js +0 -1110
  44. package/dist/globals.d.ts +0 -69
  45. package/dist/globals.js +0 -251
  46. package/dist/hooks.d.ts +0 -108
  47. package/dist/hooks.js +0 -228
  48. package/dist/index.d.ts +0 -6
  49. package/dist/index.js +0 -39
  50. package/dist/render-components.d.ts +0 -42
  51. package/dist/render-components.js +0 -154
  52. package/dist/render-metadata.d.ts +0 -122
  53. package/dist/render-metadata.js +0 -390
  54. package/dist/render-utils.d.ts +0 -166
  55. package/dist/render-utils.js +0 -398
  56. package/dist/seed.d.ts +0 -76
  57. package/dist/seed.js +0 -212
  58. package/dist/server.d.ts +0 -980
  59. package/dist/server.js +0 -2231
  60. package/dist/test.d.ts +0 -30
  61. package/dist/test.js +0 -1110
  62. package/dist/with-www-config.d.ts +0 -108
  63. package/dist/with-www-config.js +0 -1006
package/dist/config.d.ts CHANGED
@@ -1,108 +1,22 @@
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
- * Enable nested (hierarchical) Pages slugs. When `true`, the lib's
62
- * Pages collection accepts the `_` nesting divider in its slug
63
- * (`about_us` → `/about/us`). Pass the same `nested: true` to
64
- * `createCollectionPageExports` on the Pages route so URL building,
65
- * hreflang, and static params expand the divider. Default: `false`.
66
- */
67
- nested?: boolean;
68
- /**
69
- * Final say on the lib's default plugin list. Receives the
70
- * `[seoPlugin, imageHashPlugin, translator]` array; return the
71
- * list to apply. Common uses: drop the translator (no AI
72
- * translation in this project), add a second `seoPlugin({...})`
73
- * call for posts, or layer on a `formBuilderPlugin(...)`.
74
- */
75
- defaultPlugins?: (defaults: Plugin[]) => Plugin[];
76
- };
1
+ import { CollectionConfig, Config, GlobalConfig, Plugin } from "payload";
2
+ import { MCPPluginConfig } from "@payloadcms/plugin-mcp";
3
+ import { SEOPluginConfig } from "@justanarthur/payload-plugin-seo/types";
4
+ import { BlurhashPluginOptions } from "@justanarthur/payload-imagehash-plugin/types";
5
+ import { TranslatorConfig } from "@justanarthur/payload-plugin-translator/types";
77
6
  type WWWConfigApi = {
78
- withWWWConfig: (config: WWWInputConfig) => Promise<Config> | Config;
7
+ withWWWConfig: (config: WWWInputConfig) => Config;
79
8
  };
80
- type WWWInputConfig = Omit<Config, "collections" | "globals"> & {
81
- collections: ((args: {
82
- defaultCollections: CollectionConfig4[];
83
- }) => CollectionConfig4[]) | CollectionConfig4[];
84
- globals: ((args: {
85
- defaultGlobals: GlobalConfig3[];
86
- }) => GlobalConfig3[]) | GlobalConfig3[];
9
+ type WWWInputConfig = Omit<Config, "collections" | "globals" | "plugins"> & {
10
+ collections: MergeOrOverride<CollectionConfig[]>;
11
+ globals: MergeOrOverride<GlobalConfig[]>;
12
+ plugins?: MergeOrOverride<Plugin[]>;
13
+ defaultPluginsConfigs?: {
14
+ seo?: MergeOrOverride<SEOPluginConfig>;
15
+ imageHash?: MergeOrOverride<BlurhashPluginOptions>;
16
+ translator?: MergeOrOverride<TranslatorConfig>;
17
+ mcp?: MergeOrOverride<MCPPluginConfig>;
18
+ };
87
19
  };
88
- /**
89
- * Build the lib's data-config API surface, configured for a specific host.
90
- *
91
- * Hosts call this once with their `locales` and `blocks`; the returned
92
- * object is **safe to import from a Node entrypoint** such as
93
- * `payload.config.ts` — it only contains Payload collection / global
94
- * factories and the `withWWWConfig` composer.
95
- *
96
- * The lib applies three plugins by default: `seoPlugin` (Pages + meta tab),
97
- * `imageHashPlugin` (Blurhash/Thumbhash on uploads), and `translator`
98
- * (auto-translation workflow). Use the `defaultPlugins` callback to
99
- * drop or extend the list.
100
- *
101
- * For the App Router rendering side, import from the lib's render
102
- * subpaths:
103
- *
104
- * import { createCollectionPageExports } from '@justanarthur/payload-www/render-pages'
105
- * import { createPreviewHandler, createSitemapFile } from '@justanarthur/payload-www/render-utils'
106
- */
107
- declare function createWWWConfig(options: WWWConfigOptions): WWWConfigApi;
108
- export { createWWWConfig as default, createWWWConfig, WWWInputConfig, WWWConfigOptions, WWWConfigApi };
20
+ declare function createWWWConfig(): WWWConfigApi;
21
+ type MergeOrOverride<T> = T | ((defaultValue: T) => T);
22
+ export { createWWWConfig as default, createWWWConfig, WWWInputConfig, WWWConfigApi };