@nitrogenbuilder/connector-payload 0.1.28 → 0.1.29
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.
|
@@ -71,7 +71,10 @@ export const NitrogenEditButtonRuntime = ({ collection }) => {
|
|
|
71
71
|
const editorBase = instanceUrl ?? '';
|
|
72
72
|
const isDevelopmentMode = isLocalAdminHost();
|
|
73
73
|
const encodedAuthorId = encodeURIComponent(authorId);
|
|
74
|
-
const
|
|
74
|
+
const developmentFlags = isDevelopmentMode
|
|
75
|
+
? '&development=true&editorDevelopment=true'
|
|
76
|
+
: '';
|
|
77
|
+
const editHref = `${editorBase}/nitrogen-editor?token=${encodeURIComponent(token)}&collection=${encodeURIComponent(collection)}&pageId=${id}&authorId=${encodedAuthorId}&author=${encodedAuthorId}${developmentFlags}`;
|
|
75
78
|
const viewHref = collection === 'nitrogen-templates'
|
|
76
79
|
? `${frontendUrl}/nitrogen-templates/${slug}`
|
|
77
80
|
: `${frontendUrl}/${slug}`;
|
|
@@ -73,8 +73,10 @@ export function createNitrogenEditorPage(config) {
|
|
|
73
73
|
const settings = (await payload.findGlobal({
|
|
74
74
|
slug: "nitrogen-settings",
|
|
75
75
|
}));
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// `development=true` selects the preview target (`developmentUrl`) without
|
|
77
|
+
// requiring the editor shell itself to come from a local Vite server.
|
|
78
|
+
const isPreviewDevelopment = params.development === "true";
|
|
79
|
+
const siteUrl = getSiteUrl(settings, isPreviewDevelopment);
|
|
78
80
|
const nitrogenConfig = settings.nitrogenConfig || {};
|
|
79
81
|
if (!params.pageId || !params.collection) {
|
|
80
82
|
return redirect("/admin");
|
|
@@ -84,7 +86,7 @@ export function createNitrogenEditorPage(config) {
|
|
|
84
86
|
licenseKey: settings.licenseKey || "",
|
|
85
87
|
provider: {
|
|
86
88
|
type: "payload",
|
|
87
|
-
apiUrl: getNitrogenApiUrl(
|
|
89
|
+
apiUrl: getNitrogenApiUrl(isPreviewDevelopment),
|
|
88
90
|
collection: params.collection,
|
|
89
91
|
},
|
|
90
92
|
siteUrl: siteUrl || "",
|
|
@@ -93,7 +95,10 @@ export function createNitrogenEditorPage(config) {
|
|
|
93
95
|
cssInjection: nitrogenConfig.cssInjection || "",
|
|
94
96
|
};
|
|
95
97
|
const editId = params.pageId;
|
|
96
|
-
|
|
98
|
+
// Keep editor HMR opt-in separate from preview-target selection so a
|
|
99
|
+
// deployed Payload instance can still preview against a local frontend.
|
|
100
|
+
const isEditorDevelopment = params.editorDevelopment === "true";
|
|
101
|
+
const isEditorDev = isEditorDevelopment && !!settings.instanceUrl;
|
|
97
102
|
const editorOrigin = settings.instanceUrl?.replace(/\/$/, "") || "";
|
|
98
103
|
const editorAssetsBase = isEditorDev
|
|
99
104
|
? editorOrigin
|
package/package.json
CHANGED