Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: sync custom page metadata on creation (#5865)
Oleg Isonen430dc89e4bc3
diff --git a/packages/project-build/src/runtime/pages.test.ts b/packages/project-build/src/runtime/pages.test.tsindex 3e98afa856..551653a9f2 100644--- a/packages/project-build/src/runtime/pages.test.ts+++ b/packages/project-build/src/runtime/pages.test.ts@@ -1278,6 +1278,30 @@ describe("createPageUpdatePatches", () => {},]);});++ test("uses add when replacing custom metadata", () => {+ const pages = createPages();+ const page = pages.pages.get("page")!;+ page.meta.custom = [{ property: "og:title", content: '"Previous"' }];++ expect(+ createPageUpdatePatches({+ input: {+ meta: {+ custom: [{ property: "og:title", content: '"Updated"' }],+ },+ },+ page,+ pages,+ })+ ).toEqual([+ {+ op: "add",+ path: ["pages", "page", "meta", "custom"],+ value: [{ property: "og:title", content: '"Updated"' }],+ },+ ]);+ });});describe("createPageUpdatePayload", () => {diff --git a/packages/project-build/src/runtime/pages.ts b/packages/project-build/src/runtime/pages.tsindex 7878b007ee..37df70c69b 100644--- a/packages/project-build/src/runtime/pages.ts+++ b/packages/project-build/src/runtime/pages.ts@@ -1658,7 +1658,14 @@ export const createPageUpdatePatches = ({continue;}patches.push({- op: Object.hasOwn(page.meta, name) ? "replace" : "add",+ // Custom metadata is an optional array. Use `add` for the whole field+ // even when the local page already has it: JSON Patch `add` replaces an+ // object member when present, while also working for a just-created+ // page whose server copy has not received the field yet.+ op:+ name === "custom" || Object.hasOwn(page.meta, name) === false+ ? "add"+ : "replace",path: ["pages", page.id, "meta", name],value,});