@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.
- package/README.md +381 -0
- package/dist/access.d.ts +11 -0
- package/dist/access.js +34 -0
- package/dist/blocks.d.ts +24 -0
- package/dist/blocks.js +75 -0
- package/dist/collections.d.ts +200 -0
- package/dist/collections.js +625 -0
- package/dist/components.d.ts +6 -0
- package/dist/components.js +38 -0
- package/dist/config.d.ts +100 -0
- package/dist/config.js +914 -0
- package/dist/core-access.d.ts +11 -0
- package/dist/core-access.js +34 -0
- package/dist/core-blocks.d.ts +24 -0
- package/dist/core-blocks.js +75 -0
- package/dist/core-fields.d.ts +36 -0
- package/dist/core-fields.js +134 -0
- package/dist/core-utils.d.ts +16 -0
- package/dist/core-utils.js +59 -0
- package/dist/data-collections.d.ts +200 -0
- package/dist/data-collections.js +625 -0
- package/dist/data-seed.d.ts +76 -0
- package/dist/data-seed.js +212 -0
- package/dist/data-test.d.ts +30 -0
- package/dist/data-test.js +1018 -0
- package/dist/fields.d.ts +36 -0
- package/dist/fields.js +134 -0
- package/dist/globals.d.ts +48 -0
- package/dist/globals.js +228 -0
- package/dist/hooks.d.ts +108 -0
- package/dist/hooks.js +196 -0
- package/dist/imagehash.d.ts +3 -0
- package/dist/imagehash.js +24 -0
- package/dist/import-map-provider.d.ts +20 -0
- package/dist/import-map-provider.js +26 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +38 -0
- package/dist/metadata.d.ts +122 -0
- package/dist/metadata.js +335 -0
- package/dist/pages.d.ts +323 -0
- package/dist/pages.js +1016 -0
- package/dist/render-components.d.ts +42 -0
- package/dist/render-components.js +144 -0
- package/dist/render-metadata.d.ts +122 -0
- package/dist/render-metadata.js +335 -0
- package/dist/render-pages.d.ts +574 -0
- package/dist/render-pages.js +1450 -0
- package/dist/render-utils.d.ts +158 -0
- package/dist/render-utils.js +341 -0
- package/dist/seed.d.ts +76 -0
- package/dist/seed.js +212 -0
- package/dist/server.d.ts +922 -0
- package/dist/server.js +2055 -0
- package/dist/test.d.ts +30 -0
- package/dist/test.js +1018 -0
- package/dist/translator.d.ts +2 -0
- package/dist/translator.js +24 -0
- package/dist/utils.d.ts +16 -0
- package/dist/utils.js +59 -0
- package/dist/with-www-config.d.ts +100 -0
- package/dist/with-www-config.js +914 -0
- package/package.json +246 -0
|
@@ -0,0 +1,24 @@
|
|
|
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/exports/translator.ts
|
|
19
|
+
import { translator } from "@justanarthur/payload-plugin-translator";
|
|
20
|
+
var translator_default = translator;
|
|
21
|
+
export {
|
|
22
|
+
translator,
|
|
23
|
+
translator_default as default
|
|
24
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ImportMap } from "payload";
|
|
2
|
+
declare function getFromImportMap(key: string, importMap: ImportMap): any;
|
|
3
|
+
declare function generateImportName(type: "block" | "page", slug: string): string;
|
|
4
|
+
import { ImportMap as ImportMap2 } from "payload";
|
|
5
|
+
import { JSX as JSX_1kxb } from "react/jsx-runtime";
|
|
6
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
7
|
+
declare function renderCollectionModule(collection: {
|
|
8
|
+
slug: string;
|
|
9
|
+
custom?: Record<string, any>;
|
|
10
|
+
}[] | undefined, slug: string, importMap: ImportMap2, props?: Record<string, any>): Element_12xgc | null;
|
|
11
|
+
declare const _default: {
|
|
12
|
+
getFromImportMap: typeof getFromImportMap;
|
|
13
|
+
generateImportName: typeof generateImportName;
|
|
14
|
+
renderCollectionModule: typeof renderCollectionModule;
|
|
15
|
+
};
|
|
16
|
+
export { renderCollectionModule, getFromImportMap, generateImportName, _default as default };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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/core/utils/getFromImportMap.ts
|
|
19
|
+
function getFromImportMap(key, importMap) {
|
|
20
|
+
return importMap[key.includes("#") ? key : key + "#default"];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/core/utils/generateImportName.ts
|
|
24
|
+
function generateImportName(type, slug) {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case "block":
|
|
27
|
+
return `Block${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
28
|
+
case "page":
|
|
29
|
+
return `Page${slug.replace(/(^\w|-\w)/g, (m) => m.replace("-", "").toUpperCase())}#default`;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(`Unknown type: ${type}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/render/utils/renderCollectionModule.tsx
|
|
36
|
+
import { jsx } from "react/jsx-runtime";
|
|
37
|
+
function renderCollectionModule(collection = [], slug, importMap, props) {
|
|
38
|
+
const renderPath = collection?.find((c) => c.slug === slug)?.custom?.path;
|
|
39
|
+
if (!renderPath)
|
|
40
|
+
return null;
|
|
41
|
+
const CollectionRenderModule = getFromImportMap(renderPath, importMap);
|
|
42
|
+
if (!CollectionRenderModule) {
|
|
43
|
+
if (false) {}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsx(CollectionRenderModule, {
|
|
47
|
+
importMap,
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/exports/utils.ts
|
|
53
|
+
var utils_default = { getFromImportMap, generateImportName, renderCollectionModule };
|
|
54
|
+
export {
|
|
55
|
+
renderCollectionModule,
|
|
56
|
+
getFromImportMap,
|
|
57
|
+
generateImportName,
|
|
58
|
+
utils_default as default
|
|
59
|
+
};
|
|
@@ -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 };
|