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.

cleanup and reuse layout

Oleg Isonene3b2d1cec004
diff --git a/app/routes/canvas.tsx b/app/routes/canvas.tsx
index 2d08a1655f..c7766c33a2 100644
--- a/app/routes/canvas.tsx
+++ b/app/routes/canvas.tsx
@@ -1,45 +1,8 @@
-import {
- Links,
- LiveReload,
- Meta,
- Outlet as DefaultOutlet,
- Scripts,
- ScrollRestoration,
-} from "@remix-run/react";
import { type MetaFunction } from "@remix-run/node";
-import { CriticalCss } from "@webstudio-is/sdk";
+import { Canvas } from "~/shared/documents/canvas";
export const meta: MetaFunction = () => {
return { title: "Webstudio canvas" };
};
-/**
- * We are using Outlet prop from index layout when user renders site from a subdomain.
- */
-const Document = ({
- Outlet = DefaultOutlet,
-}: {
- Outlet: typeof DefaultOutlet;
-}) => {
- return (
- <html lang="en">
- <head>
- <meta charSet="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <link rel="icon" href="/favicon.ico" type="image/x-icon" />
- <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
- <Meta />
- <Links />
- <CriticalCss />
- </head>
- <body>
- <Outlet />
- <ScrollRestoration />
- <Scripts />
- {process.env.NODE_ENV === "development" && <LiveReload />}
- </body>
- </html>
- );
-};
-
-export default Document;
+export default Canvas;
diff --git a/app/routes/dashboard.tsx b/app/routes/dashboard.tsx
index 087e426344..d0721b7b36 100644
--- a/app/routes/dashboard.tsx
+++ b/app/routes/dashboard.tsx
@@ -1 +1,8 @@
-export { meta, default } from "./designer";
+import type { MetaFunction } from "@remix-run/node";
+import { Designer } from "~/shared/documents/designer";
+
+export const meta: MetaFunction = () => {
+ return { title: "Webstudio Dashboard" };
+};
+
+export default Designer;
diff --git a/app/routes/designer.tsx b/app/routes/designer.tsx
index 4ac9243a0f..103455462f 100644
--- a/app/routes/designer.tsx
+++ b/app/routes/designer.tsx
@@ -1,29 +1,8 @@
-import { Links, LiveReload, Meta, Outlet, Scripts } from "@remix-run/react";
import type { MetaFunction } from "@remix-run/node";
-import { CriticalCss } from "@webstudio-is/sdk";
-import { darkTheme } from "~/shared/design-system";
+import { Designer } from "~/shared/documents/designer";
export const meta: MetaFunction = () => {
return { title: "Webstudio" };
};
-const RootDesignerRoute = () => {
- return (
- <html lang="en">
- <head>
- <meta charSet="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <Meta />
- <Links />
- <CriticalCss />
- </head>
- <body className={darkTheme}>
- <Outlet />
- <Scripts />
- {process.env.NODE_ENV === "development" && <LiveReload />}
- </body>
- </html>
- );
-};
-
-export default RootDesignerRoute;
+export default Designer;
diff --git a/app/routes/login.tsx b/app/routes/login.tsx
new file mode 100644
index 0000000000..9371c4133e
--- /dev/null
+++ b/app/routes/login.tsx
@@ -0,0 +1,8 @@
+import { MetaFunction } from "@remix-run/node";
+import { Designer } from "~/shared/documents/designer";
+
+export const meta: MetaFunction = () => {
+ return { title: "Webstudio Login" };
+};
+
+export default Designer;
diff --git a/app/routes/login/index.tsx b/app/routes/login/index.tsx
index afaf58ce23..916b4cc724 100644
--- a/app/routes/login/index.tsx
+++ b/app/routes/login/index.tsx
@@ -1,7 +1,4 @@
-import { Links, LiveReload, Meta, Scripts } from "@remix-run/react";
-import { LoaderFunction, MetaFunction, redirect } from "@remix-run/node";
-import { CriticalCss } from "@webstudio-is/sdk";
-import { darkTheme } from "~/shared/design-system";
+import { LoaderFunction, redirect } from "@remix-run/node";
import { authenticator } from "~/services/auth.server";
import config from "~/config";
@@ -10,38 +7,17 @@ import { Login, links } from "~/auth/";
export { links };
-export const meta: MetaFunction = () => {
- return { title: "Webstudio Login" };
-};
-
-const LoginRoute = () => {
- return (
- <html lang="en">
- <head>
- <meta charSet="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <Meta />
- <Links />
- <CriticalCss />
- </head>
- <body className={darkTheme}>
- <Login />
- <Scripts />
- {process.env.NODE_ENV === "development" && <LiveReload />}
- </body>
- </html>
- );
-};
-
export const loader: LoaderFunction = async ({ request }) => {
const user = await authenticator.isAuthenticated(request);
if (user) {
return redirect(config.dashboardPath);
}
- console.log(authenticator.sessionErrorKey);
-
return {};
};
+const LoginRoute = () => {
+ return <Login />;
+};
+
export default LoginRoute;
diff --git a/app/routes/preview.tsx b/app/routes/preview.tsx
index a4cefed90e..d43bf891b4 100644
--- a/app/routes/preview.tsx
+++ b/app/routes/preview.tsx
@@ -1,2 +1,8 @@
-export * from "./canvas";
-export { default } from "./canvas";
+import { type MetaFunction } from "@remix-run/node";
+import { Canvas } from "~/shared/documents/canvas";
+
+export const meta: MetaFunction = () => {
+ return { title: "Webstudio site preview" };
+};
+
+export default Canvas;
diff --git a/app/shared/documents/canvas.tsx b/app/shared/documents/canvas.tsx
new file mode 100644
index 0000000000..c5e4c999d9
--- /dev/null
+++ b/app/shared/documents/canvas.tsx
@@ -0,0 +1,38 @@
+import {
+ Links,
+ LiveReload,
+ Meta,
+ Outlet as DefaultOutlet,
+ Scripts,
+ ScrollRestoration,
+} from "@remix-run/react";
+import { CriticalCss } from "@webstudio-is/sdk";
+
+/**
+ * We are using Outlet prop from index layout when user renders site from a subdomain.
+ */
+export const Canvas = ({
+ Outlet = DefaultOutlet,
+}: {
+ Outlet: typeof DefaultOutlet;
+}) => {
+ return (
+ <html lang="en">
+ <head>
+ <meta charSet="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" />
+ <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
+ <Meta />
+ <Links />
+ <CriticalCss />
+ </head>
+ <body>
+ <Outlet />
+ <ScrollRestoration />
+ <Scripts />
+ {process.env.NODE_ENV === "development" && <LiveReload />}
+ </body>
+ </html>
+ );
+};
diff --git a/app/shared/documents/designer.tsx b/app/shared/documents/designer.tsx
new file mode 100644
index 0000000000..1c6f5c74ad
--- /dev/null
+++ b/app/shared/documents/designer.tsx
@@ -0,0 +1,22 @@
+import { Links, LiveReload, Meta, Outlet, Scripts } from "@remix-run/react";
+import { CriticalCss } from "@webstudio-is/sdk";
+import { darkTheme } from "~/shared/design-system";
+
+export const Designer = () => {
+ return (
+ <html lang="en">
+ <head>
+ <meta charSet="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <Meta />
+ <Links />
+ <CriticalCss />
+ </head>
+ <body className={darkTheme}>
+ <Outlet />
+ <Scripts />
+ {process.env.NODE_ENV === "development" && <LiveReload />}
+ </body>
+ </html>
+ );
+};