@nitrogenbuilder/connector-payload 0.1.26 → 0.1.27
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.
|
@@ -68,10 +68,9 @@ export const NitrogenEditButtonRuntime = ({ collection }) => {
|
|
|
68
68
|
}, [collection]);
|
|
69
69
|
if (!id || !token || !authorId)
|
|
70
70
|
return null;
|
|
71
|
-
const param = collection === 'nitrogen-templates' ? 'id' : 'pageId';
|
|
72
71
|
const editorBase = instanceUrl ?? '';
|
|
73
72
|
const isDevelopmentMode = isLocalAdminHost();
|
|
74
|
-
const editHref = `${editorBase}/nitrogen-editor?token=${encodeURIComponent(token)}&collection=${encodeURIComponent(collection)}
|
|
73
|
+
const editHref = `${editorBase}/nitrogen-editor?token=${encodeURIComponent(token)}&collection=${encodeURIComponent(collection)}&pageId=${id}&authorId=${encodeURIComponent(authorId)}${isDevelopmentMode ? '&development=true' : ''}`;
|
|
75
74
|
const viewHref = collection === 'nitrogen-templates'
|
|
76
75
|
? `${frontendUrl}/nitrogen-templates/${slug}`
|
|
77
76
|
: `${frontendUrl}/${slug}`;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { SanitizedConfig } from "payload";
|
|
2
2
|
interface NitrogenEditorSearchParams {
|
|
3
|
-
id?: string;
|
|
4
3
|
pageId?: string;
|
|
5
|
-
templateId?: string;
|
|
6
4
|
collection?: string;
|
|
7
5
|
development?: string;
|
|
8
6
|
}
|
|
@@ -15,7 +13,7 @@ interface NitrogenEditorSearchParams {
|
|
|
15
13
|
* import configPromise from '@payload-config'
|
|
16
14
|
* export default createNitrogenEditorPage(configPromise)
|
|
17
15
|
*
|
|
18
|
-
* Accessible at `/nitrogen-editor?pageId=xxx
|
|
16
|
+
* Accessible at `/nitrogen-editor?pageId=xxx`.
|
|
19
17
|
*/
|
|
20
18
|
export declare function createNitrogenEditorPage(config: Promise<SanitizedConfig>): ({ searchParams, }: {
|
|
21
19
|
searchParams: Promise<NitrogenEditorSearchParams>;
|
|
@@ -57,7 +57,7 @@ function getSiteUrl(settings, isDevelopment) {
|
|
|
57
57
|
* import configPromise from '@payload-config'
|
|
58
58
|
* export default createNitrogenEditorPage(configPromise)
|
|
59
59
|
*
|
|
60
|
-
* Accessible at `/nitrogen-editor?pageId=xxx
|
|
60
|
+
* Accessible at `/nitrogen-editor?pageId=xxx`.
|
|
61
61
|
*/
|
|
62
62
|
export function createNitrogenEditorPage(config) {
|
|
63
63
|
return async function NitrogenEditorPage({ searchParams, }) {
|
|
@@ -76,15 +76,7 @@ export function createNitrogenEditorPage(config) {
|
|
|
76
76
|
const isDevelopment = params.development === "true";
|
|
77
77
|
const siteUrl = getSiteUrl(settings, isDevelopment);
|
|
78
78
|
const nitrogenConfig = settings.nitrogenConfig || {};
|
|
79
|
-
|
|
80
|
-
let postType;
|
|
81
|
-
if (params.collection) {
|
|
82
|
-
postType = params.collection;
|
|
83
|
-
}
|
|
84
|
-
else if (params.id || params.templateId) {
|
|
85
|
-
postType = "nitrogen-templates";
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
79
|
+
if (!params.pageId || !params.collection) {
|
|
88
80
|
return redirect("/admin");
|
|
89
81
|
}
|
|
90
82
|
// Build the config object the builder reads from window.nitrogenConfig
|
|
@@ -93,14 +85,14 @@ export function createNitrogenEditorPage(config) {
|
|
|
93
85
|
provider: {
|
|
94
86
|
type: "payload",
|
|
95
87
|
apiUrl: getNitrogenApiUrl(isDevelopment),
|
|
96
|
-
collection:
|
|
88
|
+
collection: params.collection,
|
|
97
89
|
},
|
|
98
90
|
siteUrl: siteUrl || "",
|
|
99
91
|
urlMaps: nitrogenConfig.urlMaps || [],
|
|
100
92
|
wysiwygColors: nitrogenConfig.wysiwygColors || {},
|
|
101
93
|
cssInjection: nitrogenConfig.cssInjection || "",
|
|
102
94
|
};
|
|
103
|
-
const editId = params.
|
|
95
|
+
const editId = params.pageId;
|
|
104
96
|
const isEditorDev = isDevelopment && !!settings.instanceUrl;
|
|
105
97
|
const editorOrigin = settings.instanceUrl?.replace(/\/$/, "") || "";
|
|
106
98
|
const editorAssetsBase = isEditorDev
|
package/package.json
CHANGED