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.

use page.title and page.meta

Roman Pominov1464abb05d63
diff --git a/apps/designer/app/routes/canvas/$projectId.$pageId.tsx b/apps/designer/app/routes/canvas/$projectId.$pageId.tsx
index f04c121a61..98b5b421b5 100644
--- a/apps/designer/app/routes/canvas/$projectId.$pageId.tsx
+++ b/apps/designer/app/routes/canvas/$projectId.$pageId.tsx
@@ -8,8 +8,12 @@ import { Root } from "@webstudio-is/react-sdk";
type Data = CanvasData | { errors: string };
-export const meta: MetaFunction = () => {
- return { title: "Webstudio canvas" };
+export const meta: MetaFunction = ({ data }: { data: Data }) => {
+ if ("errors" in data) {
+ return { title: "Error" };
+ }
+ const { page } = data;
+ return { title: page.title, ...page.meta };
};
export const loader: LoaderFunction = async ({ params }): Promise<Data> => {
diff --git a/apps/designer/app/routes/preview/$projectId.$pageId.tsx b/apps/designer/app/routes/preview/$projectId.$pageId.tsx
index bb7b388dfd..158207222f 100644
--- a/apps/designer/app/routes/preview/$projectId.$pageId.tsx
+++ b/apps/designer/app/routes/preview/$projectId.$pageId.tsx
@@ -4,12 +4,16 @@ import { loadCanvasData, type CanvasData } from "~/shared/db";
import { InstanceRoot, Root } from "@webstudio-is/react-sdk";
import { sentryException } from "~/shared/sentry";
-export const meta: MetaFunction = () => {
- return { title: "Webstudio site preview" };
-};
-
type Data = CanvasData | { errors: string };
+export const meta: MetaFunction = ({ data }: { data: Data }) => {
+ if ("errors" in data) {
+ return { title: "Error" };
+ }
+ const { page } = data;
+ return { title: page.title, ...page.meta };
+};
+
export const loader: LoaderFunction = async ({ params }): Promise<Data> => {
try {
if (params.projectId === undefined) {
diff --git a/apps/designer/app/routes/rest/patch.ts b/apps/designer/app/routes/rest/patch.ts
index ca7fb4ddf2..b3f05de21c 100644
--- a/apps/designer/app/routes/rest/patch.ts
+++ b/apps/designer/app/routes/rest/patch.ts
@@ -6,7 +6,7 @@ import { type Tree } from "@webstudio-is/react-sdk";
type PatchData = {
transactions: Array<SyncItem>;
- treeId: Tree["id"]; // @todo: it would be more correct to pass Page["id"] here
+ treeId: Tree["id"];
buildId: Build["id"];
};
diff --git a/apps/designer/app/shared/db/canvas.server.ts b/apps/designer/app/shared/db/canvas.server.ts
index 26f4100ce1..1b05f12c13 100644
--- a/apps/designer/app/shared/db/canvas.server.ts
+++ b/apps/designer/app/shared/db/canvas.server.ts
@@ -3,7 +3,7 @@ import type { Project, Build, Page } from "@webstudio-is/project";
import { db } from "@webstudio-is/project/index.server";
import { utils } from "@webstudio-is/project";
-export type CanvasData = Data & { buildId: Build["id"] };
+export type CanvasData = Data & { buildId: Build["id"]; page: Page };
export const loadCanvasData = async (
projectId: Project["id"],
@@ -41,7 +41,8 @@ export const loadCanvasData = async (
return {
tree,
props,
- buildId: devBuild.id,
breakpoints: breakpoints.values,
+ buildId: devBuild.id,
+ page,
};
};