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
feat: Add custom metadata to page settings form (#2552)
Ivan Starkovf51b0f19ddd6
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsxindex 10db394238..1f7daca74c 100644--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsx+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsx@@ -60,6 +60,7 @@ import { ImageControl } from "~/builder/features/seo/image-control";import { ImageInfo } from "./image-info";import { SocialPreview } from "./social-preview";import { useEffectEvent } from "~/builder/features/ai/hooks/effect-event";+import { CustomMetadata } from "./custom-metadata";const fieldDefaultValues = {name: "Untitled",@@ -69,6 +70,12 @@ const fieldDefaultValues = {isHomePage: false,excludePageFromSearch: false,socialImageAssetId: "",+ customMetas: [+ {+ property: "",+ content: "",+ },+ ],};const fieldNames = Object.keys(@@ -145,10 +152,14 @@ const toFormPage = (page: Page, isHomePage: boolean): Values => {name: page.name,path: page.path,title: page.title,- description: page.meta.description ?? "",- socialImageAssetId: page.meta.socialImageAssetId ?? "",- excludePageFromSearch: page.meta.excludePageFromSearch ?? false,+ description: page.meta.description ?? fieldDefaultValues.description,+ socialImageAssetId:+ page.meta.socialImageAssetId ?? fieldDefaultValues.socialImageAssetId,+ excludePageFromSearch:+ page.meta.excludePageFromSearch ??+ fieldDefaultValues.excludePageFromSearch,isHomePage,+ customMetas: page.meta.custom ?? fieldDefaultValues.customMetas,};};@@ -485,6 +496,19 @@ const FormFields = ({ogDescription={values.description}/></Grid>++ <Separator />++ <CustomMetadata+ customMetas={values.customMetas}+ onChange={(customMetas) => {+ onChange({+ field: "customMetas",+ value: customMetas,+ });+ }}+ />+ <Box css={{ height: theme.spacing[10] }} /></ScrollArea></Grid>);@@ -676,6 +700,10 @@ const updatePage = (pageId: Page["id"], values: Partial<Values>) => {if (values.socialImageAssetId !== undefined) {page.meta.socialImageAssetId = values.socialImageAssetId;}++ if (values.customMetas !== undefined) {+ page.meta.custom = values.customMetas;+ }};serverSyncStore.createTransaction([pagesStore], (pages) => {diff --git a/fixtures/webstudio-custom-template/app/routes/_index.tsx b/fixtures/webstudio-custom-template/app/routes/_index.tsxindex 9858cc75de..464d4729ba 100644--- a/fixtures/webstudio-custom-template/app/routes/_index.tsx+++ b/fixtures/webstudio-custom-template/app/routes/_index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsxindex 9858cc75de..464d4729ba 100644--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsxindex 9858cc75de..464d4729ba 100644--- a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/fixtures/webstudio-remix-vercel/.webstudio/data.json b/fixtures/webstudio-remix-vercel/.webstudio/data.jsonindex 56d6d17add..f1cfd2fdf4 100644--- a/fixtures/webstudio-remix-vercel/.webstudio/data.json+++ b/fixtures/webstudio-remix-vercel/.webstudio/data.json@@ -1,9 +1,9 @@{"build": {- "id": "9ec8b651-0491-4237-9516-88c0bded9af8",+ "id": "e21f5897-41b4-4850-971a-ff6f8badf388","projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",- "version": 214,- "createdAt": "2023-10-30T20:58:37.229Z",+ "version": 217,+ "createdAt": "2023-11-02T17:03:37.356Z","pages": {"meta": {"siteName": "KittyGuardedZone",@@ -16,7 +16,13 @@"title": "The Ultimate Cat Protection Zone","meta": {"description": "Dive into the world of felines and discover why some whiskers are best left untouched. From intriguing cat behaviors to protective measures, \nKittyGuardedZone is your go-to hub for all things 'hands-off' in the cat realm.",- "socialImageAssetId": "cd939c56-bcdd-4e64-bd9c-567a9bccd3da"+ "socialImageAssetId": "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",+ "custom": [+ {+ "property": "fb:app_id",+ "content": "app_id_app_id_app_id"+ }+ ]},"rootInstanceId": "On9cvWCxr5rdZtY9O1Bv0","path": ""@@ -3143,7 +3149,13 @@"title": "The Ultimate Cat Protection Zone","meta": {"description": "Dive into the world of felines and discover why some whiskers are best left untouched. From intriguing cat behaviors to protective measures, \nKittyGuardedZone is your go-to hub for all things 'hands-off' in the cat realm.",- "socialImageAssetId": "cd939c56-bcdd-4e64-bd9c-567a9bccd3da"+ "socialImageAssetId": "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",+ "custom": [+ {+ "property": "fb:app_id",+ "content": "app_id_app_id_app_id"+ }+ ]},"rootInstanceId": "On9cvWCxr5rdZtY9O1Bv0","path": ""@@ -3155,7 +3167,13 @@"title": "The Ultimate Cat Protection Zone","meta": {"description": "Dive into the world of felines and discover why some whiskers are best left untouched. From intriguing cat behaviors to protective measures, \nKittyGuardedZone is your go-to hub for all things 'hands-off' in the cat realm.",- "socialImageAssetId": "cd939c56-bcdd-4e64-bd9c-567a9bccd3da"+ "socialImageAssetId": "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",+ "custom": [+ {+ "property": "fb:app_id",+ "content": "app_id_app_id_app_id"+ }+ ]},"rootInstanceId": "On9cvWCxr5rdZtY9O1Bv0","path": ""diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsxindex 370098c958..846f931be0 100644--- a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx+++ b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx@@ -64,6 +64,7 @@ export const pageData: PageData = {description:"Dive into the world of felines and discover why some whiskers are best left untouched. From intriguing cat behaviors to protective measures, \nKittyGuardedZone is your go-to hub for all things 'hands-off' in the cat realm.",socialImageAssetId: "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",+ custom: [{ property: "fb:app_id", content: "app_id_app_id_app_id" }],},rootInstanceId: "On9cvWCxr5rdZtY9O1Bv0",path: "",diff --git a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsxindex fc3210c542..16324c16ba 100644--- a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx+++ b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsxindex 755d77a645..075776c874 100644--- a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx+++ b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsxindex 9ee9d035af..cc83d6e036 100644--- a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx+++ b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsxindex a34cc204d7..d5a1ab0b8f 100644--- a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx b/fixtures/webstudio-remix-vercel/app/routes/_index.tsxindex 9858cc75de..464d4729ba 100644--- a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx+++ b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/packages/cli/templates/route-template.tsx b/packages/cli/templates/route-template.tsxindex 68c9f3a597..ae71c7b02f 100644--- a/packages/cli/templates/route-template.tsx+++ b/packages/cli/templates/route-template.tsx@@ -135,6 +135,13 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {}}+ for (const customMeta of page.meta.custom ?? []) {+ if (customMeta.property.trim().length === 0) {+ continue;+ }+ metas.push(customMeta);+ }+return metas;};diff --git a/packages/sdk/src/schema/pages.ts b/packages/sdk/src/schema/pages.tsindex 052eda0a2a..5c9c9bf096 100644--- a/packages/sdk/src/schema/pages.ts+++ b/packages/sdk/src/schema/pages.ts@@ -22,6 +22,14 @@ const commonPageFields = {title: z.string().optional(),excludePageFromSearch: z.boolean().optional(),socialImageAssetId: z.string().optional(),+ custom: z+ .array(+ z.object({+ property: z.string(),+ content: z.string(),+ })+ )+ .optional(),}),rootInstanceId: z.string(),} as const;