Skip to content

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.

experimental: allow changing page status (#2905)

Bogdan Chadkin646245f21af7
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx
index ea5237005d..491ac4fbeb 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx
@@ -90,6 +90,7 @@ const fieldDefaultValues = {
excludePageFromSearch: `false`,
socialImageUrl: `""`,
socialImageAssetId: "",
+ status: `200`,
redirect: `""`,
customMetas: [
{
@@ -137,12 +138,22 @@ const LegacyPagePath = z
const EmptyString = z.string().refine((string) => string === "");
+// 2xx, 3xx, 4xx, 5xx
+const statusRegex = /^[2345]\d\d$/;
+const Status = z
+ .number()
+ .refine(
+ (value) => statusRegex.test(String(value)),
+ "Status code expects 2xx, 3xx, 4xx or 5xx"
+ );
+
const SharedPageValues = z.object({
name: PageName,
title: PageTitle,
description: z.string().optional(),
excludePageFromSearch: z.boolean().optional(),
socialImageUrl: z.string().optional(),
+ status: Status.optional(),
redirect: z.optional(ProjectNewRedirectPath.or(EmptyString)),
customMetas: z
.array(
@@ -199,6 +210,7 @@ const validateValues = (
variableValues
),
socialImageUrl: computeExpression(values.socialImageUrl, variableValues),
+ status: computeExpression(values.status, variableValues),
redirect: computeExpression(values.redirect, variableValues),
customMetas: values.customMetas.map((item) => ({
property: item.property,
@@ -244,6 +256,7 @@ const toFormValues = (
excludePageFromSearch:
page.meta.excludePageFromSearch ??
fieldDefaultValues.excludePageFromSearch,
+ status: page.meta.status ?? fieldDefaultValues.status,
redirect: page.meta.redirect ?? fieldDefaultValues.redirect,
isHomePage,
customMetas: page.meta.custom ?? fieldDefaultValues.customMetas,
@@ -299,7 +312,6 @@ const FormFields = ({
const excludePageFromSearch = Boolean(
computeExpression(values.excludePageFromSearch, variableValues)
);
- const redirect = String(computeExpression(values.redirect, variableValues));
return (
<Grid css={{ height: "100%" }}>
@@ -607,6 +619,59 @@ const FormFields = ({
</BindingControl>
</Grid>
+ {isFeatureEnabled("cms") && (
+ <Grid gap={1}>
+ <Label htmlFor={fieldIds.status}>Status</Label>
+ <BindingControl>
+ <BindingPopover
+ scope={scope}
+ aliases={aliases}
+ variant={
+ isLiteralExpression(values.status) ? "default" : "bound"
+ }
+ value={values.status}
+ onChange={(value) => {
+ onChange({
+ field: "status",
+ value,
+ });
+ }}
+ onRemove={(evaluatedValue) => {
+ onChange({
+ field: "status",
+ value: JSON.stringify(evaluatedValue),
+ });
+ }}
+ />
+ <InputErrorsTooltip errors={errors.status}>
+ <InputField
+ inputMode="numeric"
+ color={errors.status && "error"}
+ id={fieldIds.status}
+ name="status"
+ placeholder="/another-path"
+ disabled={
+ disabled || isLiteralExpression(values.status) === false
+ }
+ value={String(
+ computeExpression(values.status, variableValues)
+ )}
+ onChange={(event) => {
+ const number = Number(event.target.value);
+ const status = Number.isNaN(number)
+ ? event.target.value
+ : number;
+ onChange({
+ field: "status",
+ value: JSON.stringify(status),
+ });
+ }}
+ />
+ </InputErrorsTooltip>
+ </BindingControl>
+ </Grid>
+ )}
+
{isFeatureEnabled("cms") && (
<Grid gap={1}>
<Label htmlFor={fieldIds.redirect}>Redirect</Label>
@@ -640,7 +705,9 @@ const FormFields = ({
disabled={
disabled || isLiteralExpression(values.redirect) === false
}
- value={redirect}
+ value={String(
+ computeExpression(values.redirect, variableValues)
+ )}
onChange={(event) => {
onChange({
field: "redirect",
@@ -977,6 +1044,10 @@ const updatePage = (
page.meta.excludePageFromSearch = values.excludePageFromSearch;
}
+ if (values.status !== undefined) {
+ page.meta.status = values.status;
+ }
+
if (values.redirect !== undefined) {
page.meta.redirect =
values.redirect.length > 0 ? values.redirect : undefined;
diff --git a/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx b/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx
index 30d06de34a..ef530a4639 100644
--- a/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/__generated__/[script-test]._index.tsx
@@ -51,6 +51,7 @@ export const getPageMeta = ({
excludePageFromSearch: false,
socialImageAssetId: "",
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-custom-template/app/__generated__/_index.tsx b/fixtures/webstudio-custom-template/app/__generated__/_index.tsx
index 36fbe673e4..67ea92148e 100644
--- a/fixtures/webstudio-custom-template/app/__generated__/_index.tsx
+++ b/fixtures/webstudio-custom-template/app/__generated__/_index.tsx
@@ -51,6 +51,7 @@ export const getPageMeta = ({
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/_index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/_index.tsx
index f0836d9ba1..c6caa53d5d 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/__generated__/_index.tsx
@@ -35,6 +35,7 @@ export const getPageMeta = ({
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
index 9d672c2c5c..9c7c675a4a 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/fixtures/webstudio-remix-netlify-functions/app/__generated__/_index.tsx b/fixtures/webstudio-remix-netlify-functions/app/__generated__/_index.tsx
index f0836d9ba1..c6caa53d5d 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/__generated__/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/__generated__/_index.tsx
@@ -35,6 +35,7 @@ export const getPageMeta = ({
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
index 9d672c2c5c..9c7c675a4a 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx
index 8332074c8e..0d8bb431a7 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx
@@ -70,6 +70,7 @@ export const getPageMeta = ({
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[form]._index.tsx
index f207eb8494..70c05fe94d 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[form]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[form]._index.tsx
@@ -79,6 +79,7 @@ export const getPageMeta = ({
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[heading-with-id]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[heading-with-id]._index.tsx
index e5972d7d07..9a5fb96785 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[heading-with-id]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[heading-with-id]._index.tsx
@@ -70,6 +70,7 @@ export const getPageMeta = ({
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[nested].[nested-page]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[nested].[nested-page]._index.tsx
index 5432137dbd..4d98dc6d27 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[nested].[nested-page]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[nested].[nested-page]._index.tsx
@@ -70,6 +70,7 @@ export const getPageMeta = ({
excludePageFromSearch: false,
socialImageAssetId: "",
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
index 713fb6aba7..0ff2cd4629 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
@@ -82,6 +82,7 @@ export const getPageMeta = ({
excludePageFromSearch: true,
socialImageAssetId: "88d5e2ff-b8f2-4899-aaf8-dde4ade6da10",
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.tsx
index 16ea5a014d..6b0b96baed 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[resources]._index.tsx
@@ -73,6 +73,7 @@ export const getPageMeta = ({
excludePageFromSearch: false,
socialImageAssetId: "",
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [],
};
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
index bbf09a74e0..afce23e18f 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
@@ -80,6 +80,7 @@ export const getPageMeta = ({
excludePageFromSearch: undefined,
socialImageAssetId: "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [
{
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.tsx
index 65503872e0..c0d90ad167 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
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
index 0f25e54bef..1301281d9c 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
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.tsx
index 8521b78200..b8fa6e7080 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
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
index 809af67ba0..a8c7aad728 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
index 3b4ef76046..5321c74663 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
index ee884c2b70..b6893d0c8c 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
index 9d672c2c5c..9c7c675a4a 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/packages/cli/templates/defaults/__templates__/route-template.tsx b/packages/cli/templates/defaults/__templates__/route-template.tsx
index 1232734dbc..b091d41667 100644
--- a/packages/cli/templates/defaults/__templates__/route-template.tsx
+++ b/packages/cli/templates/defaults/__templates__/route-template.tsx
@@ -38,7 +38,11 @@ export const loader = async (arg: LoaderArgs) => {
const pageMeta = getPageMeta({ params, resources });
if (pageMeta.redirect) {
- return redirect(pageMeta.redirect, 302);
+ const status =
+ pageMeta.status === 301 || pageMeta.status === 302
+ ? pageMeta.status
+ : 302;
+ return redirect(pageMeta.redirect, status);
}
const host =
@@ -64,7 +68,10 @@ export const loader = async (arg: LoaderArgs) => {
},
// No way for current information to change, so add cache for 10 minutes
// In case of CRM Data, this should be set to 0
- { headers: { "Cache-Control": "public, max-age=600" } }
+ {
+ status: pageMeta.status,
+ headers: { "Cache-Control": "public, max-age=600" },
+ }
);
};
diff --git a/packages/react-sdk/src/page-meta-generator.test.ts b/packages/react-sdk/src/page-meta-generator.test.ts
index 7f18360f4f..6b2931e971 100644
--- a/packages/react-sdk/src/page-meta-generator.test.ts
+++ b/packages/react-sdk/src/page-meta-generator.test.ts
@@ -33,6 +33,7 @@ test("generate minimal static page meta factory", () => {
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [
],
@@ -56,6 +57,7 @@ test("generate complete static page meta factory", () => {
description: `"Page description"`,
excludePageFromSearch: "true",
socialImageAssetId: "social-image-name",
+ status: `302`,
redirect: `"/new-path"`,
custom: [
{ property: "custom-property-1", content: `"custom content 1"` },
@@ -79,6 +81,7 @@ test("generate complete static page meta factory", () => {
excludePageFromSearch: true,
socialImageAssetId: "social-image-name",
socialImageUrl: undefined,
+ status: 302,
redirect: "/new-path",
custom: [
{
@@ -126,6 +129,7 @@ test("generate asset url instead of id", () => {
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: "https://my-image",
+ status: undefined,
redirect: undefined,
custom: [
],
@@ -168,6 +172,7 @@ test("generate custom meta ignoring empty property name", () => {
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [
{
@@ -218,6 +223,7 @@ test("generate page meta factory with variables", () => {
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [
],
@@ -264,6 +270,7 @@ test("generate page meta factory with path params", () => {
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [
],
@@ -310,6 +317,7 @@ test("generate page meta factory with resources", () => {
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [
],
@@ -377,6 +385,7 @@ test("generate page meta factory without unused variables", () => {
excludePageFromSearch: undefined,
socialImageAssetId: undefined,
socialImageUrl: undefined,
+ status: undefined,
redirect: undefined,
custom: [
],
diff --git a/packages/react-sdk/src/page-meta-generator.ts b/packages/react-sdk/src/page-meta-generator.ts
index ebe33a7b9b..3efdeb5215 100644
--- a/packages/react-sdk/src/page-meta-generator.ts
+++ b/packages/react-sdk/src/page-meta-generator.ts
@@ -13,6 +13,7 @@ export type PageMeta = {
excludePageFromSearch?: boolean;
socialImageAssetId?: Asset["id"];
socialImageUrl?: string;
+ status?: number;
redirect?: string;
custom: Array<{ property: string; content: string }>;
};
@@ -56,6 +57,12 @@ export const generatePageMeta = ({
usedDataSources,
scope: localScope,
});
+ const statusExpression = generateExpression({
+ expression: page.meta.status ?? "undefined",
+ dataSources,
+ usedDataSources,
+ scope: localScope,
+ });
const redirectExpression = generateExpression({
expression: page.meta.redirect ?? "undefined",
dataSources,
@@ -120,6 +127,7 @@ export const generatePageMeta = ({
generated += ` excludePageFromSearch: ${excludePageFromSearchExpression},\n`;
generated += ` socialImageAssetId: ${socialImageAssetIdExpression},\n`;
generated += ` socialImageUrl: ${socialImageUrlExpression},\n`;
+ generated += ` status: ${statusExpression},\n`;
generated += ` redirect: ${redirectExpression},\n`;
generated += ` custom: ${customExpression},\n`;
generated += ` };\n`;
diff --git a/packages/sdk/src/schema/pages.ts b/packages/sdk/src/schema/pages.ts
index d41c28cfb7..4a459b65bf 100644
--- a/packages/sdk/src/schema/pages.ts
+++ b/packages/sdk/src/schema/pages.ts
@@ -46,6 +46,7 @@ const commonPageFields = {
excludePageFromSearch: z.string().optional(),
socialImageAssetId: z.string().optional(),
socialImageUrl: z.string().optional(),
+ status: z.string().optional(),
redirect: z.string().optional(),
custom: z
.array(