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.

Escape special characters in route names in cli projects (#2288)

Jaya Krishna Namburu0de3bca3502e
diff --git a/fixtures/webstudio-remix-vercel/.webstudio/data.json b/fixtures/webstudio-remix-vercel/.webstudio/data.json
index 1931249b7b..ae5103dd13 100644
--- a/fixtures/webstudio-remix-vercel/.webstudio/data.json
+++ b/fixtures/webstudio-remix-vercel/.webstudio/data.json
@@ -23,6 +23,36 @@
},
"rootInstanceId": "uKWGyE9JY3cPwY-xI9vk6",
"path": "/radix"
+ },
+ {
+ "id": "w9Qwfu1HOP397jLNtq-hc",
+ "name": "Blog",
+ "title": "Blog",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "xDnAIGJjaOVjOfMU6bbxQ",
+ "path": "/blog"
+ },
+ {
+ "id": "hd6G3bz113YtoxD-3lNAI",
+ "name": "Page",
+ "title": "Page",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "nEyRUCIYmfkBYUb-MSdDd",
+ "path": "/blog/page"
+ },
+ {
+ "id": "FGakc6C75caW7hRRn_0lZ",
+ "name": "deep-nested-page",
+ "title": "deep-nested-page",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "P_qm1M69qwe6M2aaNBzOH",
+ "path": "/blog/page/deep-nested-page"
}
]
},
@@ -2191,6 +2221,144 @@
}
]
}
+ ],
+ [
+ "xDnAIGJjaOVjOfMU6bbxQ",
+ {
+ "type": "instance",
+ "id": "xDnAIGJjaOVjOfMU6bbxQ",
+ "component": "Body",
+ "children": [
+ {
+ "type": "id",
+ "value": "JemPdaC7WmuopS5GTRaRZ"
+ },
+ {
+ "type": "id",
+ "value": "FZ3JS5mYbAWT3EyQexnaS"
+ }
+ ]
+ }
+ ],
+ [
+ "JemPdaC7WmuopS5GTRaRZ",
+ {
+ "type": "instance",
+ "id": "JemPdaC7WmuopS5GTRaRZ",
+ "component": "Heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "Blog"
+ }
+ ]
+ }
+ ],
+ [
+ "FZ3JS5mYbAWT3EyQexnaS",
+ {
+ "type": "instance",
+ "id": "FZ3JS5mYbAWT3EyQexnaS",
+ "component": "Link",
+ "children": [
+ {
+ "type": "text",
+ "value": "Link text you can edit"
+ }
+ ]
+ }
+ ],
+ [
+ "nEyRUCIYmfkBYUb-MSdDd",
+ {
+ "type": "instance",
+ "id": "nEyRUCIYmfkBYUb-MSdDd",
+ "component": "Body",
+ "children": [
+ {
+ "type": "id",
+ "value": "oX13CSOxZaPn94ukbUaW3"
+ },
+ {
+ "type": "id",
+ "value": "M4cBN9R79h4ZxP8IlqmFp"
+ }
+ ]
+ }
+ ],
+ [
+ "oX13CSOxZaPn94ukbUaW3",
+ {
+ "type": "instance",
+ "id": "oX13CSOxZaPn94ukbUaW3",
+ "component": "Heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "Page"
+ }
+ ]
+ }
+ ],
+ [
+ "M4cBN9R79h4ZxP8IlqmFp",
+ {
+ "type": "instance",
+ "id": "M4cBN9R79h4ZxP8IlqmFp",
+ "component": "Link",
+ "children": [
+ {
+ "type": "text",
+ "value": "Link text you can edit"
+ }
+ ]
+ }
+ ],
+ [
+ "P_qm1M69qwe6M2aaNBzOH",
+ {
+ "type": "instance",
+ "id": "P_qm1M69qwe6M2aaNBzOH",
+ "component": "Body",
+ "children": [
+ {
+ "type": "id",
+ "value": "UG0MSNfRWyyac4KR3fFyg"
+ },
+ {
+ "type": "id",
+ "value": "Zh_5yzptz6BB60Va6TlVv"
+ }
+ ]
+ }
+ ],
+ [
+ "UG0MSNfRWyyac4KR3fFyg",
+ {
+ "type": "instance",
+ "id": "UG0MSNfRWyyac4KR3fFyg",
+ "component": "Heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "Deep nested"
+ }
+ ]
+ }
+ ],
+ [
+ "Zh_5yzptz6BB60Va6TlVv",
+ {
+ "type": "instance",
+ "id": "Zh_5yzptz6BB60Va6TlVv",
+ "component": "Link",
+ "children": [
+ {
+ "type": "text",
+ "value": "Link text you can edit"
+ }
+ ]
+ }
]
],
"deployment": {
@@ -2224,6 +2392,36 @@
},
"rootInstanceId": "uKWGyE9JY3cPwY-xI9vk6",
"path": "/radix"
+ },
+ {
+ "id": "w9Qwfu1HOP397jLNtq-hc",
+ "name": "Blog",
+ "title": "Blog",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "xDnAIGJjaOVjOfMU6bbxQ",
+ "path": "/blog"
+ },
+ {
+ "id": "hd6G3bz113YtoxD-3lNAI",
+ "name": "Page",
+ "title": "Page",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "nEyRUCIYmfkBYUb-MSdDd",
+ "path": "/blog/page"
+ },
+ {
+ "id": "FGakc6C75caW7hRRn_0lZ",
+ "name": "deep-nested-page",
+ "title": "deep-nested-page",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "P_qm1M69qwe6M2aaNBzOH",
+ "path": "/blog/page/deep-nested-page"
}
],
"assets": [
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[blog].[page].[deep-nested-page]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[blog].[page].[deep-nested-page]._index.tsx
new file mode 100644
index 0000000000..ed5fa098e1
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[blog].[page].[deep-nested-page]._index.tsx
@@ -0,0 +1,176 @@
+/* eslint-disable */
+/* This is a auto generated file for building the project */
+
+import * as sdk from "@webstudio-is/react-sdk";
+import type { PageData } from "~/routes/_index";
+import type { Components } from "@webstudio-is/react-sdk";
+import type { Asset } from "@webstudio-is/sdk";
+import {
+ Body as Body,
+ Heading as Heading,
+} from "@webstudio-is/sdk-components-react";
+import { Link as Link } from "@webstudio-is/sdk-components-react-remix";
+
+export const components = new Map(
+ Object.entries({ Body: Body, Heading: Heading, Link: Link })
+) as Components;
+export const fontAssets: Asset[] = [];
+export const pageData: PageData = {
+ build: {
+ props: [],
+ instances: [
+ [
+ "P_qm1M69qwe6M2aaNBzOH",
+ {
+ type: "instance",
+ id: "P_qm1M69qwe6M2aaNBzOH",
+ component: "Body",
+ children: [
+ { type: "id", value: "UG0MSNfRWyyac4KR3fFyg" },
+ { type: "id", value: "Zh_5yzptz6BB60Va6TlVv" },
+ ],
+ },
+ ],
+ [
+ "UG0MSNfRWyyac4KR3fFyg",
+ {
+ type: "instance",
+ id: "UG0MSNfRWyyac4KR3fFyg",
+ component: "Heading",
+ children: [{ type: "text", value: "Deep nested" }],
+ },
+ ],
+ [
+ "Zh_5yzptz6BB60Va6TlVv",
+ {
+ type: "instance",
+ id: "Zh_5yzptz6BB60Va6TlVv",
+ component: "Link",
+ children: [{ type: "text", value: "Link text you can edit" }],
+ },
+ ],
+ ],
+ dataSources: [],
+ },
+ pages: [
+ {
+ id: "7Db64ZXgYiRqKSQNR-qTQ",
+ name: "Home",
+ title: "Home",
+ meta: {},
+ rootInstanceId: "On9cvWCxr5rdZtY9O1Bv0",
+ path: "",
+ },
+ {
+ id: "xfvB4UThQXmQ_OubPYrkg",
+ name: "radix",
+ title: "radix",
+ meta: { description: "" },
+ rootInstanceId: "uKWGyE9JY3cPwY-xI9vk6",
+ path: "/radix",
+ },
+ {
+ id: "w9Qwfu1HOP397jLNtq-hc",
+ name: "Blog",
+ title: "Blog",
+ meta: { description: "" },
+ rootInstanceId: "xDnAIGJjaOVjOfMU6bbxQ",
+ path: "/blog",
+ },
+ {
+ id: "hd6G3bz113YtoxD-3lNAI",
+ name: "Page",
+ title: "Page",
+ meta: { description: "" },
+ rootInstanceId: "nEyRUCIYmfkBYUb-MSdDd",
+ path: "/blog/page",
+ },
+ {
+ id: "FGakc6C75caW7hRRn_0lZ",
+ name: "deep-nested-page",
+ title: "deep-nested-page",
+ meta: { description: "" },
+ rootInstanceId: "P_qm1M69qwe6M2aaNBzOH",
+ path: "/blog/page/deep-nested-page",
+ },
+ ],
+ page: {
+ id: "FGakc6C75caW7hRRn_0lZ",
+ name: "deep-nested-page",
+ title: "deep-nested-page",
+ meta: { description: "" },
+ rootInstanceId: "P_qm1M69qwe6M2aaNBzOH",
+ path: "/blog/page/deep-nested-page",
+ },
+ assets: [
+ {
+ id: "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",
+ name: "_937084ed-a798-49fe-8664-df93a2af605e_uiBk3o6UWdqolyakMvQJ9.jpeg",
+ description: null,
+ projectId: "cddc1d44-af37-4cb6-a430-d300cf6f932d",
+ size: 210614,
+ type: "image",
+ format: "jpeg",
+ createdAt: "2023-09-06T11:28:43.031Z",
+ meta: { width: 1024, height: 1024 },
+ },
+ ],
+};
+export const user: { email: string | null } | undefined = {
+ email: "[email protected]",
+};
+export const projectId = "cddc1d44-af37-4cb6-a430-d300cf6f932d";
+
+/* eslint-disable */
+
+const indexesWithinAncestors = new Map<string, number>([]);
+
+const rawExecuteComputingExpressions = (
+ _variables: Map<string, unknown>
+): Map<string, unknown> => {
+ return new Map([]);
+};
+const executeComputingExpressions = (variables: Map<string, unknown>) => {
+ const encodedvariables = sdk.encodeVariablesMap(variables);
+ const encodedResult = rawExecuteComputingExpressions(encodedvariables);
+ return sdk.decodeVariablesMap(encodedResult);
+};
+
+const generatedEffectfulExpressions = new Map<
+ string,
+ (args: Map<string, any>, variables: Map<string, any>) => Map<string, unknown>
+>([]);
+
+const rawExecuteEffectfulExpression = (
+ code: string,
+ args: Map<string, unknown>,
+ variables: Map<string, unknown>
+): Map<string, unknown> => {
+ if (generatedEffectfulExpressions.has(code)) {
+ return generatedEffectfulExpressions.get(code)!(args, variables);
+ }
+ console.error("Effectful expression not found", code);
+ throw new Error("Effectful expression not found");
+};
+
+const executeEffectfulExpression = (
+ code: string,
+ args: Map<string, unknown>,
+ variables: Map<string, unknown>
+) => {
+ const encodedvariables = sdk.encodeVariablesMap(variables);
+ const encodedResult = rawExecuteEffectfulExpression(
+ code,
+ args,
+ encodedvariables
+ );
+ return sdk.decodeVariablesMap(encodedResult);
+};
+
+export const utils = {
+ indexesWithinAncestors,
+ executeComputingExpressions,
+ executeEffectfulExpression,
+};
+
+/* eslint-enable */
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[blog].[page]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[blog].[page]._index.tsx
new file mode 100644
index 0000000000..8ead282d40
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[blog].[page]._index.tsx
@@ -0,0 +1,176 @@
+/* eslint-disable */
+/* This is a auto generated file for building the project */
+
+import * as sdk from "@webstudio-is/react-sdk";
+import type { PageData } from "~/routes/_index";
+import type { Components } from "@webstudio-is/react-sdk";
+import type { Asset } from "@webstudio-is/sdk";
+import {
+ Body as Body,
+ Heading as Heading,
+} from "@webstudio-is/sdk-components-react";
+import { Link as Link } from "@webstudio-is/sdk-components-react-remix";
+
+export const components = new Map(
+ Object.entries({ Body: Body, Heading: Heading, Link: Link })
+) as Components;
+export const fontAssets: Asset[] = [];
+export const pageData: PageData = {
+ build: {
+ props: [],
+ instances: [
+ [
+ "nEyRUCIYmfkBYUb-MSdDd",
+ {
+ type: "instance",
+ id: "nEyRUCIYmfkBYUb-MSdDd",
+ component: "Body",
+ children: [
+ { type: "id", value: "oX13CSOxZaPn94ukbUaW3" },
+ { type: "id", value: "M4cBN9R79h4ZxP8IlqmFp" },
+ ],
+ },
+ ],
+ [
+ "oX13CSOxZaPn94ukbUaW3",
+ {
+ type: "instance",
+ id: "oX13CSOxZaPn94ukbUaW3",
+ component: "Heading",
+ children: [{ type: "text", value: "Page" }],
+ },
+ ],
+ [
+ "M4cBN9R79h4ZxP8IlqmFp",
+ {
+ type: "instance",
+ id: "M4cBN9R79h4ZxP8IlqmFp",
+ component: "Link",
+ children: [{ type: "text", value: "Link text you can edit" }],
+ },
+ ],
+ ],
+ dataSources: [],
+ },
+ pages: [
+ {
+ id: "7Db64ZXgYiRqKSQNR-qTQ",
+ name: "Home",
+ title: "Home",
+ meta: {},
+ rootInstanceId: "On9cvWCxr5rdZtY9O1Bv0",
+ path: "",
+ },
+ {
+ id: "xfvB4UThQXmQ_OubPYrkg",
+ name: "radix",
+ title: "radix",
+ meta: { description: "" },
+ rootInstanceId: "uKWGyE9JY3cPwY-xI9vk6",
+ path: "/radix",
+ },
+ {
+ id: "w9Qwfu1HOP397jLNtq-hc",
+ name: "Blog",
+ title: "Blog",
+ meta: { description: "" },
+ rootInstanceId: "xDnAIGJjaOVjOfMU6bbxQ",
+ path: "/blog",
+ },
+ {
+ id: "hd6G3bz113YtoxD-3lNAI",
+ name: "Page",
+ title: "Page",
+ meta: { description: "" },
+ rootInstanceId: "nEyRUCIYmfkBYUb-MSdDd",
+ path: "/blog/page",
+ },
+ {
+ id: "FGakc6C75caW7hRRn_0lZ",
+ name: "deep-nested-page",
+ title: "deep-nested-page",
+ meta: { description: "" },
+ rootInstanceId: "P_qm1M69qwe6M2aaNBzOH",
+ path: "/blog/page/deep-nested-page",
+ },
+ ],
+ page: {
+ id: "hd6G3bz113YtoxD-3lNAI",
+ name: "Page",
+ title: "Page",
+ meta: { description: "" },
+ rootInstanceId: "nEyRUCIYmfkBYUb-MSdDd",
+ path: "/blog/page",
+ },
+ assets: [
+ {
+ id: "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",
+ name: "_937084ed-a798-49fe-8664-df93a2af605e_uiBk3o6UWdqolyakMvQJ9.jpeg",
+ description: null,
+ projectId: "cddc1d44-af37-4cb6-a430-d300cf6f932d",
+ size: 210614,
+ type: "image",
+ format: "jpeg",
+ createdAt: "2023-09-06T11:28:43.031Z",
+ meta: { width: 1024, height: 1024 },
+ },
+ ],
+};
+export const user: { email: string | null } | undefined = {
+ email: "[email protected]",
+};
+export const projectId = "cddc1d44-af37-4cb6-a430-d300cf6f932d";
+
+/* eslint-disable */
+
+const indexesWithinAncestors = new Map<string, number>([]);
+
+const rawExecuteComputingExpressions = (
+ _variables: Map<string, unknown>
+): Map<string, unknown> => {
+ return new Map([]);
+};
+const executeComputingExpressions = (variables: Map<string, unknown>) => {
+ const encodedvariables = sdk.encodeVariablesMap(variables);
+ const encodedResult = rawExecuteComputingExpressions(encodedvariables);
+ return sdk.decodeVariablesMap(encodedResult);
+};
+
+const generatedEffectfulExpressions = new Map<
+ string,
+ (args: Map<string, any>, variables: Map<string, any>) => Map<string, unknown>
+>([]);
+
+const rawExecuteEffectfulExpression = (
+ code: string,
+ args: Map<string, unknown>,
+ variables: Map<string, unknown>
+): Map<string, unknown> => {
+ if (generatedEffectfulExpressions.has(code)) {
+ return generatedEffectfulExpressions.get(code)!(args, variables);
+ }
+ console.error("Effectful expression not found", code);
+ throw new Error("Effectful expression not found");
+};
+
+const executeEffectfulExpression = (
+ code: string,
+ args: Map<string, unknown>,
+ variables: Map<string, unknown>
+) => {
+ const encodedvariables = sdk.encodeVariablesMap(variables);
+ const encodedResult = rawExecuteEffectfulExpression(
+ code,
+ args,
+ encodedvariables
+ );
+ return sdk.decodeVariablesMap(encodedResult);
+};
+
+export const utils = {
+ indexesWithinAncestors,
+ executeComputingExpressions,
+ executeEffectfulExpression,
+};
+
+/* eslint-enable */
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[blog]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[blog]._index.tsx
new file mode 100644
index 0000000000..4f992bf5f1
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[blog]._index.tsx
@@ -0,0 +1,176 @@
+/* eslint-disable */
+/* This is a auto generated file for building the project */
+
+import * as sdk from "@webstudio-is/react-sdk";
+import type { PageData } from "~/routes/_index";
+import type { Components } from "@webstudio-is/react-sdk";
+import type { Asset } from "@webstudio-is/sdk";
+import {
+ Body as Body,
+ Heading as Heading,
+} from "@webstudio-is/sdk-components-react";
+import { Link as Link } from "@webstudio-is/sdk-components-react-remix";
+
+export const components = new Map(
+ Object.entries({ Body: Body, Heading: Heading, Link: Link })
+) as Components;
+export const fontAssets: Asset[] = [];
+export const pageData: PageData = {
+ build: {
+ props: [],
+ instances: [
+ [
+ "xDnAIGJjaOVjOfMU6bbxQ",
+ {
+ type: "instance",
+ id: "xDnAIGJjaOVjOfMU6bbxQ",
+ component: "Body",
+ children: [
+ { type: "id", value: "JemPdaC7WmuopS5GTRaRZ" },
+ { type: "id", value: "FZ3JS5mYbAWT3EyQexnaS" },
+ ],
+ },
+ ],
+ [
+ "JemPdaC7WmuopS5GTRaRZ",
+ {
+ type: "instance",
+ id: "JemPdaC7WmuopS5GTRaRZ",
+ component: "Heading",
+ children: [{ type: "text", value: "Blog" }],
+ },
+ ],
+ [
+ "FZ3JS5mYbAWT3EyQexnaS",
+ {
+ type: "instance",
+ id: "FZ3JS5mYbAWT3EyQexnaS",
+ component: "Link",
+ children: [{ type: "text", value: "Link text you can edit" }],
+ },
+ ],
+ ],
+ dataSources: [],
+ },
+ pages: [
+ {
+ id: "7Db64ZXgYiRqKSQNR-qTQ",
+ name: "Home",
+ title: "Home",
+ meta: {},
+ rootInstanceId: "On9cvWCxr5rdZtY9O1Bv0",
+ path: "",
+ },
+ {
+ id: "xfvB4UThQXmQ_OubPYrkg",
+ name: "radix",
+ title: "radix",
+ meta: { description: "" },
+ rootInstanceId: "uKWGyE9JY3cPwY-xI9vk6",
+ path: "/radix",
+ },
+ {
+ id: "w9Qwfu1HOP397jLNtq-hc",
+ name: "Blog",
+ title: "Blog",
+ meta: { description: "" },
+ rootInstanceId: "xDnAIGJjaOVjOfMU6bbxQ",
+ path: "/blog",
+ },
+ {
+ id: "hd6G3bz113YtoxD-3lNAI",
+ name: "Page",
+ title: "Page",
+ meta: { description: "" },
+ rootInstanceId: "nEyRUCIYmfkBYUb-MSdDd",
+ path: "/blog/page",
+ },
+ {
+ id: "FGakc6C75caW7hRRn_0lZ",
+ name: "deep-nested-page",
+ title: "deep-nested-page",
+ meta: { description: "" },
+ rootInstanceId: "P_qm1M69qwe6M2aaNBzOH",
+ path: "/blog/page/deep-nested-page",
+ },
+ ],
+ page: {
+ id: "w9Qwfu1HOP397jLNtq-hc",
+ name: "Blog",
+ title: "Blog",
+ meta: { description: "" },
+ rootInstanceId: "xDnAIGJjaOVjOfMU6bbxQ",
+ path: "/blog",
+ },
+ assets: [
+ {
+ id: "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",
+ name: "_937084ed-a798-49fe-8664-df93a2af605e_uiBk3o6UWdqolyakMvQJ9.jpeg",
+ description: null,
+ projectId: "cddc1d44-af37-4cb6-a430-d300cf6f932d",
+ size: 210614,
+ type: "image",
+ format: "jpeg",
+ createdAt: "2023-09-06T11:28:43.031Z",
+ meta: { width: 1024, height: 1024 },
+ },
+ ],
+};
+export const user: { email: string | null } | undefined = {
+ email: "[email protected]",
+};
+export const projectId = "cddc1d44-af37-4cb6-a430-d300cf6f932d";
+
+/* eslint-disable */
+
+const indexesWithinAncestors = new Map<string, number>([]);
+
+const rawExecuteComputingExpressions = (
+ _variables: Map<string, unknown>
+): Map<string, unknown> => {
+ return new Map([]);
+};
+const executeComputingExpressions = (variables: Map<string, unknown>) => {
+ const encodedvariables = sdk.encodeVariablesMap(variables);
+ const encodedResult = rawExecuteComputingExpressions(encodedvariables);
+ return sdk.decodeVariablesMap(encodedResult);
+};
+
+const generatedEffectfulExpressions = new Map<
+ string,
+ (args: Map<string, any>, variables: Map<string, any>) => Map<string, unknown>
+>([]);
+
+const rawExecuteEffectfulExpression = (
+ code: string,
+ args: Map<string, unknown>,
+ variables: Map<string, unknown>
+): Map<string, unknown> => {
+ if (generatedEffectfulExpressions.has(code)) {
+ return generatedEffectfulExpressions.get(code)!(args, variables);
+ }
+ console.error("Effectful expression not found", code);
+ throw new Error("Effectful expression not found");
+};
+
+const executeEffectfulExpression = (
+ code: string,
+ args: Map<string, unknown>,
+ variables: Map<string, unknown>
+) => {
+ const encodedvariables = sdk.encodeVariablesMap(variables);
+ const encodedResult = rawExecuteEffectfulExpression(
+ code,
+ args,
+ encodedvariables
+ );
+ return sdk.decodeVariablesMap(encodedResult);
+};
+
+export const utils = {
+ indexesWithinAncestors,
+ executeComputingExpressions,
+ executeEffectfulExpression,
+};
+
+/* eslint-enable */
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/radix._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
similarity index 95%
rename from fixtures/webstudio-remix-vercel/app/__generated__/radix._index.tsx
rename to fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
index 6e2d7194c0..ca1cb392d8 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/radix._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
@@ -398,6 +398,30 @@ export const pageData: PageData = {
rootInstanceId: "uKWGyE9JY3cPwY-xI9vk6",
path: "/radix",
},
+ {
+ id: "w9Qwfu1HOP397jLNtq-hc",
+ name: "Blog",
+ title: "Blog",
+ meta: { description: "" },
+ rootInstanceId: "xDnAIGJjaOVjOfMU6bbxQ",
+ path: "/blog",
+ },
+ {
+ id: "hd6G3bz113YtoxD-3lNAI",
+ name: "Page",
+ title: "Page",
+ meta: { description: "" },
+ rootInstanceId: "nEyRUCIYmfkBYUb-MSdDd",
+ path: "/blog/page",
+ },
+ {
+ id: "FGakc6C75caW7hRRn_0lZ",
+ name: "deep-nested-page",
+ title: "deep-nested-page",
+ meta: { description: "" },
+ rootInstanceId: "P_qm1M69qwe6M2aaNBzOH",
+ path: "/blog/page/deep-nested-page",
+ },
],
page: {
id: "xfvB4UThQXmQ_OubPYrkg",
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
index d51077abba..6cc65ab753 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
@@ -174,6 +174,30 @@ export const pageData: PageData = {
rootInstanceId: "uKWGyE9JY3cPwY-xI9vk6",
path: "/radix",
},
+ {
+ id: "w9Qwfu1HOP397jLNtq-hc",
+ name: "Blog",
+ title: "Blog",
+ meta: { description: "" },
+ rootInstanceId: "xDnAIGJjaOVjOfMU6bbxQ",
+ path: "/blog",
+ },
+ {
+ id: "hd6G3bz113YtoxD-3lNAI",
+ name: "Page",
+ title: "Page",
+ meta: { description: "" },
+ rootInstanceId: "nEyRUCIYmfkBYUb-MSdDd",
+ path: "/blog/page",
+ },
+ {
+ id: "FGakc6C75caW7hRRn_0lZ",
+ name: "deep-nested-page",
+ title: "deep-nested-page",
+ meta: { description: "" },
+ rootInstanceId: "P_qm1M69qwe6M2aaNBzOH",
+ path: "/blog/page/deep-nested-page",
+ },
],
page: {
id: "7Db64ZXgYiRqKSQNR-qTQ",
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[blog].[page].[deep-nested-page]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[blog].[page].[deep-nested-page]._index.tsx
new file mode 100644
index 0000000000..1dd14d02f1
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/routes/[blog].[page].[deep-nested-page]._index.tsx
@@ -0,0 +1,181 @@
+/* eslint-disable camelcase */
+import {
+ V2_MetaFunction,
+ LinksFunction,
+ LinkDescriptor,
+ ActionArgs,
+ json,
+} from "@remix-run/node";
+
+import {
+ InstanceRoot,
+ type RootPropsData,
+ type Params,
+} from "@webstudio-is/react-sdk";
+import { n8nHandler, getFormProperties } from "@webstudio-is/form-handlers";
+import { Scripts, ScrollRestoration } from "@remix-run/react";
+import {
+ fontAssets,
+ components,
+ pageData,
+ user,
+ projectId,
+ utils,
+} from "../__generated__/[blog].[page].[deep-nested-page]._index.tsx";
+import css from "../__generated__/index.css";
+import type { Data } from "@webstudio-is/http-client";
+
+export type PageData = Omit<Data, "build"> & {
+ build: Pick<Data["build"], "props" | "instances" | "dataSources">;
+};
+
+export const meta: V2_MetaFunction = () => {
+ const { page } = pageData;
+ return [{ title: page?.title || "Webstudio", ...page?.meta }];
+};
+
+export const links: LinksFunction = () => {
+ const result: LinkDescriptor[] = [];
+
+ result.push({
+ rel: "stylesheet",
+ href: css,
+ });
+
+ for (const asset of fontAssets) {
+ if (asset.type === "font") {
+ result.push({
+ rel: "preload",
+ href: "/assets/" + asset.name,
+ as: "font",
+ crossOrigin: "anonymous",
+ // @todo add mimeType
+ // type: asset.mimeType,
+ });
+ }
+ }
+
+ return result;
+};
+
+const getRequestHost = (request: Request): string =>
+ request.headers.get("x-forwarded-host") || request.headers.get("host") || "";
+
+const getMethod = (value: string | undefined) => {
+ if (value === undefined) {
+ return "post";
+ }
+
+ switch (value.toLowerCase()) {
+ case "get":
+ return "get";
+ default:
+ return "post";
+ }
+};
+
+export const action = async ({ request, context }: ActionArgs) => {
+ const formData = await request.formData();
+
+ const formProperties = getFormProperties(formData, pageData.build.props);
+
+ if (formProperties === undefined) {
+ // We're throwing rather than returning { success: false }
+ // because this isn't supposed to happen normally: bug or malicious user
+ throw json("Form not found", { status: 404 });
+ }
+
+ const { action, method } = formProperties;
+
+ const email = user?.email;
+
+ if (email == null) {
+ return { success: false };
+ }
+
+ // wrapped in try/catch just in cases new URL() throws
+ // (should not happen)
+ let pageUrl: URL;
+ try {
+ pageUrl = new URL(request.url);
+ pageUrl.host = getRequestHost(request);
+ } catch {
+ return { success: false };
+ }
+
+ if (action !== undefined) {
+ try {
+ // Test that action is full URL
+ new URL(action);
+ } catch {
+ return json(
+ {
+ success: false,
+ error: "Invalid action URL, must be valid http/https protocol",
+ },
+ { status: 200 }
+ );
+ }
+ }
+
+ const formInfo = {
+ formData,
+ projectId,
+ action: action ?? null,
+ method: getMethod(method),
+ pageUrl: pageUrl.toString(),
+ toEmail: email,
+ fromEmail: pageUrl.hostname + "@webstudio.email",
+ } as const;
+
+ const result = await n8nHandler({
+ formInfo,
+ hookUrl: context.N8N_FORM_EMAIL_HOOK as string,
+ });
+
+ return result;
+};
+
+const Outlet = () => {
+ const pagesCanvasData: PageData = pageData;
+
+ const page = pagesCanvasData.page;
+
+ if (page === undefined) {
+ throw json("Page not found", {
+ status: 404,
+ });
+ }
+
+ const assetBaseUrl = "/assets/";
+ const imageBaseUrl = "/assets/";
+
+ const params: Params = {
+ assetBaseUrl,
+ imageBaseUrl,
+ };
+
+ const data: RootPropsData = {
+ build: pagesCanvasData.build,
+ assets: pagesCanvasData.assets,
+ page,
+ pages: pagesCanvasData.pages,
+ params,
+ };
+
+ return (
+ <InstanceRoot
+ data={data}
+ components={components}
+ utils={utils}
+ scripts={
+ <>
+ <Scripts />
+ <ScrollRestoration />
+ </>
+ }
+ />
+ );
+};
+
+export default Outlet;
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[blog].[page]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[blog].[page]._index.tsx
new file mode 100644
index 0000000000..2258620f56
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/routes/[blog].[page]._index.tsx
@@ -0,0 +1,181 @@
+/* eslint-disable camelcase */
+import {
+ V2_MetaFunction,
+ LinksFunction,
+ LinkDescriptor,
+ ActionArgs,
+ json,
+} from "@remix-run/node";
+
+import {
+ InstanceRoot,
+ type RootPropsData,
+ type Params,
+} from "@webstudio-is/react-sdk";
+import { n8nHandler, getFormProperties } from "@webstudio-is/form-handlers";
+import { Scripts, ScrollRestoration } from "@remix-run/react";
+import {
+ fontAssets,
+ components,
+ pageData,
+ user,
+ projectId,
+ utils,
+} from "../__generated__/[blog].[page]._index.tsx";
+import css from "../__generated__/index.css";
+import type { Data } from "@webstudio-is/http-client";
+
+export type PageData = Omit<Data, "build"> & {
+ build: Pick<Data["build"], "props" | "instances" | "dataSources">;
+};
+
+export const meta: V2_MetaFunction = () => {
+ const { page } = pageData;
+ return [{ title: page?.title || "Webstudio", ...page?.meta }];
+};
+
+export const links: LinksFunction = () => {
+ const result: LinkDescriptor[] = [];
+
+ result.push({
+ rel: "stylesheet",
+ href: css,
+ });
+
+ for (const asset of fontAssets) {
+ if (asset.type === "font") {
+ result.push({
+ rel: "preload",
+ href: "/assets/" + asset.name,
+ as: "font",
+ crossOrigin: "anonymous",
+ // @todo add mimeType
+ // type: asset.mimeType,
+ });
+ }
+ }
+
+ return result;
+};
+
+const getRequestHost = (request: Request): string =>
+ request.headers.get("x-forwarded-host") || request.headers.get("host") || "";
+
+const getMethod = (value: string | undefined) => {
+ if (value === undefined) {
+ return "post";
+ }
+
+ switch (value.toLowerCase()) {
+ case "get":
+ return "get";
+ default:
+ return "post";
+ }
+};
+
+export const action = async ({ request, context }: ActionArgs) => {
+ const formData = await request.formData();
+
+ const formProperties = getFormProperties(formData, pageData.build.props);
+
+ if (formProperties === undefined) {
+ // We're throwing rather than returning { success: false }
+ // because this isn't supposed to happen normally: bug or malicious user
+ throw json("Form not found", { status: 404 });
+ }
+
+ const { action, method } = formProperties;
+
+ const email = user?.email;
+
+ if (email == null) {
+ return { success: false };
+ }
+
+ // wrapped in try/catch just in cases new URL() throws
+ // (should not happen)
+ let pageUrl: URL;
+ try {
+ pageUrl = new URL(request.url);
+ pageUrl.host = getRequestHost(request);
+ } catch {
+ return { success: false };
+ }
+
+ if (action !== undefined) {
+ try {
+ // Test that action is full URL
+ new URL(action);
+ } catch {
+ return json(
+ {
+ success: false,
+ error: "Invalid action URL, must be valid http/https protocol",
+ },
+ { status: 200 }
+ );
+ }
+ }
+
+ const formInfo = {
+ formData,
+ projectId,
+ action: action ?? null,
+ method: getMethod(method),
+ pageUrl: pageUrl.toString(),
+ toEmail: email,
+ fromEmail: pageUrl.hostname + "@webstudio.email",
+ } as const;
+
+ const result = await n8nHandler({
+ formInfo,
+ hookUrl: context.N8N_FORM_EMAIL_HOOK as string,
+ });
+
+ return result;
+};
+
+const Outlet = () => {
+ const pagesCanvasData: PageData = pageData;
+
+ const page = pagesCanvasData.page;
+
+ if (page === undefined) {
+ throw json("Page not found", {
+ status: 404,
+ });
+ }
+
+ const assetBaseUrl = "/assets/";
+ const imageBaseUrl = "/assets/";
+
+ const params: Params = {
+ assetBaseUrl,
+ imageBaseUrl,
+ };
+
+ const data: RootPropsData = {
+ build: pagesCanvasData.build,
+ assets: pagesCanvasData.assets,
+ page,
+ pages: pagesCanvasData.pages,
+ params,
+ };
+
+ return (
+ <InstanceRoot
+ data={data}
+ components={components}
+ utils={utils}
+ scripts={
+ <>
+ <Scripts />
+ <ScrollRestoration />
+ </>
+ }
+ />
+ );
+};
+
+export default Outlet;
diff --git a/fixtures/webstudio-remix-vercel/app/routes/radix._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[blog]._index.tsx
similarity index 98%
rename from fixtures/webstudio-remix-vercel/app/routes/radix._index.tsx
rename to fixtures/webstudio-remix-vercel/app/routes/[blog]._index.tsx
index a8f794b64d..4761d5fcfc 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/radix._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[blog]._index.tsx
@@ -21,7 +21,7 @@ import {
user,
projectId,
utils,
-} from "../__generated__/radix._index.tsx";
+} from "../__generated__/[blog]._index.tsx";
import css from "../__generated__/index.css";
import type { Data } from "@webstudio-is/http-client";
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
new file mode 100644
index 0000000000..bcbf1a5f0e
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
@@ -0,0 +1,181 @@
+/* eslint-disable camelcase */
+import {
+ V2_MetaFunction,
+ LinksFunction,
+ LinkDescriptor,
+ ActionArgs,
+ json,
+} from "@remix-run/node";
+
+import {
+ InstanceRoot,
+ type RootPropsData,
+ type Params,
+} from "@webstudio-is/react-sdk";
+import { n8nHandler, getFormProperties } from "@webstudio-is/form-handlers";
+import { Scripts, ScrollRestoration } from "@remix-run/react";
+import {
+ fontAssets,
+ components,
+ pageData,
+ user,
+ projectId,
+ utils,
+} from "../__generated__/[radix]._index.tsx";
+import css from "../__generated__/index.css";
+import type { Data } from "@webstudio-is/http-client";
+
+export type PageData = Omit<Data, "build"> & {
+ build: Pick<Data["build"], "props" | "instances" | "dataSources">;
+};
+
+export const meta: V2_MetaFunction = () => {
+ const { page } = pageData;
+ return [{ title: page?.title || "Webstudio", ...page?.meta }];
+};
+
+export const links: LinksFunction = () => {
+ const result: LinkDescriptor[] = [];
+
+ result.push({
+ rel: "stylesheet",
+ href: css,
+ });
+
+ for (const asset of fontAssets) {
+ if (asset.type === "font") {
+ result.push({
+ rel: "preload",
+ href: "/assets/" + asset.name,
+ as: "font",
+ crossOrigin: "anonymous",
+ // @todo add mimeType
+ // type: asset.mimeType,
+ });
+ }
+ }
+
+ return result;
+};
+
+const getRequestHost = (request: Request): string =>
+ request.headers.get("x-forwarded-host") || request.headers.get("host") || "";
+
+const getMethod = (value: string | undefined) => {
+ if (value === undefined) {
+ return "post";
+ }
+
+ switch (value.toLowerCase()) {
+ case "get":
+ return "get";
+ default:
+ return "post";
+ }
+};
+
+export const action = async ({ request, context }: ActionArgs) => {
+ const formData = await request.formData();
+
+ const formProperties = getFormProperties(formData, pageData.build.props);
+
+ if (formProperties === undefined) {
+ // We're throwing rather than returning { success: false }
+ // because this isn't supposed to happen normally: bug or malicious user
+ throw json("Form not found", { status: 404 });
+ }
+
+ const { action, method } = formProperties;
+
+ const email = user?.email;
+
+ if (email == null) {
+ return { success: false };
+ }
+
+ // wrapped in try/catch just in cases new URL() throws
+ // (should not happen)
+ let pageUrl: URL;
+ try {
+ pageUrl = new URL(request.url);
+ pageUrl.host = getRequestHost(request);
+ } catch {
+ return { success: false };
+ }
+
+ if (action !== undefined) {
+ try {
+ // Test that action is full URL
+ new URL(action);
+ } catch {
+ return json(
+ {
+ success: false,
+ error: "Invalid action URL, must be valid http/https protocol",
+ },
+ { status: 200 }
+ );
+ }
+ }
+
+ const formInfo = {
+ formData,
+ projectId,
+ action: action ?? null,
+ method: getMethod(method),
+ pageUrl: pageUrl.toString(),
+ toEmail: email,
+ fromEmail: pageUrl.hostname + "@webstudio.email",
+ } as const;
+
+ const result = await n8nHandler({
+ formInfo,
+ hookUrl: context.N8N_FORM_EMAIL_HOOK as string,
+ });
+
+ return result;
+};
+
+const Outlet = () => {
+ const pagesCanvasData: PageData = pageData;
+
+ const page = pagesCanvasData.page;
+
+ if (page === undefined) {
+ throw json("Page not found", {
+ status: 404,
+ });
+ }
+
+ const assetBaseUrl = "/assets/";
+ const imageBaseUrl = "/assets/";
+
+ const params: Params = {
+ assetBaseUrl,
+ imageBaseUrl,
+ };
+
+ const data: RootPropsData = {
+ build: pagesCanvasData.build,
+ assets: pagesCanvasData.assets,
+ page,
+ pages: pagesCanvasData.pages,
+ params,
+ };
+
+ return (
+ <InstanceRoot
+ data={data}
+ components={components}
+ utils={utils}
+ scripts={
+ <>
+ <Scripts />
+ <ScrollRestoration />
+ </>
+ }
+ />
+ );
+};
+
+export default Outlet;
diff --git a/packages/cli/src/prebuild.ts b/packages/cli/src/prebuild.ts
index c4b2459565..31f89e9e81 100644
--- a/packages/cli/src/prebuild.ts
+++ b/packages/cli/src/prebuild.ts
@@ -385,10 +385,25 @@ export const projectId = "${siteData.build.projectId}";
${utilsExport}
`;
+ /*
+ The _index is mandatory.
+ Let's say there is a route /test.one.tsx and then there is a /test.tsx route.
+ Remix doesn't pick the /test.tsx by default unless we mention the _index at the end.
+
+ Or else it picks the first route that matches the /test as a layout and not a independent route.
+ So, we need to mark the pages as _index at the end. So deep nested routes works as expected.
+
+ Details:
+ https://remix.run/docs/en/main/file-conventions/route-files-v2#nested-urls-without-layout-nesting
+ */
+
const fileName =
pathName === "main" || pathName === "index"
? "_index.tsx"
- : `${pathName.split("/").join(".")}._index.tsx`;
+ : `${pathName
+ .split("/")
+ .map((route) => `[${route}]`)
+ .join(".")}._index.tsx`;
let routeFile = getRouteTemplate();