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.

feat: Add title support to HeadSlot (#4758)

Ivan Starkov3cf9f315fdc8
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 3cbe0e7ad5..3fec2ba4d1 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -22,7 +22,7 @@ jobs:
DATABASE_URL: postgres://
AUTH_SECRET: test
- runs-on: ubuntu-latest
+ runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
diff --git a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
index 5cbf8d8ab9..6e12e779ed 100644
--- a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
+++ b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
index 7a204fa27b..8c2322120c 100644
--- a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
index 79c59d4627..ea6c11a80c 100644
--- a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
index 982d22ada9..6d2d7d8bc7 100644
--- a/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-custom-template/app/routes/_index.tsx b/fixtures/webstudio-custom-template/app/routes/_index.tsx
index 7a204fa27b..8c2322120c 100644
--- a/fixtures/webstudio-custom-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/_index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx
index 5cbf8d8ab9..6e12e779ed 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
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 7a204fa27b..8c2322120c 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx
index 5cbf8d8ab9..6e12e779ed 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
index 7a204fa27b..8c2322120c 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/.webstudio/data.json b/fixtures/webstudio-remix-vercel/.webstudio/data.json
index b04938cbee..4703bb0d05 100644
--- a/fixtures/webstudio-remix-vercel/.webstudio/data.json
+++ b/fixtures/webstudio-remix-vercel/.webstudio/data.json
@@ -1,10 +1,10 @@
{
"build": {
- "id": "39af85c6-952a-42a5-953b-67718e2b95d7",
+ "id": "0d43a990-f5cd-43c3-ab26-863ebe71eb27",
"projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",
- "version": 455,
- "createdAt": "2025-01-18T13:58:20.219+00:00",
- "updatedAt": "2025-01-18T13:58:20.219+00:00",
+ "version": 463,
+ "createdAt": "2025-01-18T19:56:10.675+00:00",
+ "updatedAt": "2025-01-18T19:56:10.675+00:00",
"pages": {
"meta": {
"siteName": "KittyGuardedZone",
@@ -2979,6 +2979,16 @@
"type": "string",
"value": "og:title"
}
+ ],
+ [
+ "Eo5zG6ibHI2ueliryZsqN",
+ {
+ "id": "Eo5zG6ibHI2ueliryZsqN",
+ "instanceId": "f0kF-WmL7DQg7MSyRvqY1",
+ "name": "data-ws-show",
+ "type": "boolean",
+ "value": true
+ }
]
],
"dataSources": [
@@ -5011,6 +5021,10 @@
"id": "Jdxu-0HI2f6Lq-LJwIOyY",
"component": "HeadSlot",
"children": [
+ {
+ "type": "id",
+ "value": "4DTeDG3l8nX_C_oNtaHZQ"
+ },
{
"type": "id",
"value": "GFN6suio87WybEb7dc8IM"
@@ -5083,6 +5097,21 @@
"label": "Meta",
"children": []
}
+ ],
+ [
+ "4DTeDG3l8nX_C_oNtaHZQ",
+ {
+ "type": "instance",
+ "id": "4DTeDG3l8nX_C_oNtaHZQ",
+ "component": "HeadTitle",
+ "label": "Title",
+ "children": [
+ {
+ "type": "text",
+ "value": "Head Slot Title"
+ }
+ ]
+ }
]
],
"deployment": {
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[head-tag]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[head-tag]._index.tsx
index e2e7157ea3..cd9110e865 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[head-tag]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[head-tag]._index.tsx
@@ -13,6 +13,7 @@ import {
HeadLink as HeadLink,
HeadMeta as HeadMeta,
Heading as Heading,
+ HeadTitle as HeadTitle,
} from "@webstudio-is/sdk-components-react";
export const siteName = "KittyGuardedZone";
@@ -36,8 +37,9 @@ export const pageBackgroundImageAssets: ImageAsset[] = [];
const Page = ({}: { system: any }) => {
return (
- <Body className={"w-body"}>
+ <Body className={`w-body`}>
<HeadSlot>
+ <HeadTitle>{"Head Slot Title"}</HeadTitle>
<HeadLink rel={"help"} href={"/help-head-slot"} />
<HeadMeta name={"keywords"} content={"Head Slot Content"} />
<HeadMeta
@@ -46,8 +48,8 @@ const Page = ({}: { system: any }) => {
property={"og:title"}
/>
</HeadSlot>
- <Heading className={"w-heading"}>{"Test Head Slot"}</Heading>
- <Link href={"/"} className={"w-link"}>
+ <Heading className={`w-heading`}>{"Test Head Slot"}</Heading>
+ <Link href={"/"} className={`w-link`}>
{"Go Home"}
</Link>
</Body>
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 4c00fa5ad5..d7486e7268 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
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[class-names]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[class-names]._index.tsx
index 10877776f8..42f6e9655b 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[class-names]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[class-names]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[content-block]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[content-block]._index.tsx
index c54dee3181..b0767715c7 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[content-block]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[content-block]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[expressions]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[expressions]._index.tsx
index 60e5dbd29f..6badc800b2 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[expressions]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[expressions]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
index 8372680d8d..38a92c2b70 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[head-tag]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[head-tag]._index.tsx
index 47c854a5ac..b617f702d6 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[head-tag]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[head-tag]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
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 e861209120..3411491cd6 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
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
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 1295311a6f..f6c0d0796d 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
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
index b5921ec842..48c413cc19 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
index 98275731d3..2b874c673d 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
index 7a204fa27b..8c2322120c 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/fixtures/webstudio-remix-vercel/package.json b/fixtures/webstudio-remix-vercel/package.json
index cfb75b14c5..f6c1a14f3f 100644
--- a/fixtures/webstudio-remix-vercel/package.json
+++ b/fixtures/webstudio-remix-vercel/package.json
@@ -6,7 +6,7 @@
"typecheck": "tsc",
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
"fixtures:link": "pnpm cli link --link https://p-cddc1d44-af37-4cb6-a430-d300cf6f932d-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=1cdc6026-dd5b-4624-b89b-9bd45e9bcc3d'",
- "fixtures:sync": "pnpm cli sync --buildId 39af85c6-952a-42a5-953b-67718e2b95d7 && pnpm prettier --write ./.webstudio/",
+ "fixtures:sync": "pnpm cli sync --buildId 0d43a990-f5cd-43c3-ab26-863ebe71eb27 && pnpm prettier --write ./.webstudio/",
"fixtures:build": "pnpm cli build --template vercel --template internal --template ./.template && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
},
"private": true,
diff --git a/fixtures/webstudio-remix-vercel/proxy-emulator/dedupe-meta.ts b/fixtures/webstudio-remix-vercel/proxy-emulator/dedupe-meta.ts
index 3da113d734..20257b027f 100644
--- a/fixtures/webstudio-remix-vercel/proxy-emulator/dedupe-meta.ts
+++ b/fixtures/webstudio-remix-vercel/proxy-emulator/dedupe-meta.ts
@@ -35,33 +35,45 @@ export const dedupeMeta: Plugin = {
const response = new Response(body);
const metasSet = new Set<string>();
+ let hasTitle = false;
- const rewriter = new HTMLRewriter().on("meta", {
- element(element) {
- const propertyOrName =
- element.getAttribute("property") ||
- element.getAttribute("name");
-
- if (propertyOrName === null) {
- return;
- }
-
- if (propertyOrName === "viewport") {
- // Allow "viewport" property deduplication
- return;
- }
-
- if (metasSet.has(propertyOrName)) {
- console.info(
- `Duplicate meta with name|property = ${propertyOrName} removed`
- );
- element.remove();
- return;
- }
-
- metasSet.add(propertyOrName);
- },
- });
+ const rewriter = new HTMLRewriter()
+ .on("meta", {
+ element(element) {
+ const propertyOrName =
+ element.getAttribute("property") ||
+ element.getAttribute("name");
+
+ if (propertyOrName === null) {
+ return;
+ }
+
+ if (propertyOrName === "viewport") {
+ // Allow "viewport" property deduplication
+ return;
+ }
+
+ if (metasSet.has(propertyOrName)) {
+ console.info(
+ `Duplicate meta with name|property = ${propertyOrName} removed`
+ );
+ element.remove();
+ return;
+ }
+
+ metasSet.add(propertyOrName);
+ },
+ })
+ .on("title", {
+ element(element) {
+ if (hasTitle) {
+ element.remove();
+ return;
+ }
+
+ hasTitle = true;
+ },
+ });
rewriter
// @ts-ignore
.transform(response)
diff --git a/packages/cli/templates/defaults/app/route-templates/html.tsx b/packages/cli/templates/defaults/app/route-templates/html.tsx
index d5ea8061eb..1609162d8e 100644
--- a/packages/cli/templates/defaults/app/route-templates/html.tsx
+++ b/packages/cli/templates/defaults/app/route-templates/html.tsx
@@ -19,6 +19,7 @@ import {
import {
ReactSdkContext,
PageSettingsMeta,
+ PageSettingsTitle,
} from "@webstudio-is/react-sdk/runtime";
import {
Page,
@@ -121,13 +122,8 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
return metas;
}
- const { pageMeta } = data;
const origin = `https://${data.host}`;
- if (pageMeta.title) {
- metas.push({ title: pageMeta.title });
- }
-
if (siteName) {
metas.push({
"script:ld+json": {
@@ -291,6 +287,7 @@ const Outlet = () => {
siteName={siteName}
imageLoader={imageLoader}
/>
+ <PageSettingsTitle>{pageMeta.title}</PageSettingsTitle>
</ReactSdkContext.Provider>
);
};
diff --git a/packages/react-sdk/src/page-settings-meta.tsx b/packages/react-sdk/src/page-settings-meta.tsx
index c71514ac4e..a0f179c2c7 100644
--- a/packages/react-sdk/src/page-settings-meta.tsx
+++ b/packages/react-sdk/src/page-settings-meta.tsx
@@ -9,7 +9,7 @@ type MetaProps = {
};
// Not documented
-const isElementRenderedWithReact = (element: Element) => {
+export const isElementRenderedWithReact = (element: Element) => {
return Object.keys(element).some((key) => key.startsWith("__react"));
};
diff --git a/packages/react-sdk/src/page-settings-title.tsx b/packages/react-sdk/src/page-settings-title.tsx
new file mode 100644
index 0000000000..ada5ea6ceb
--- /dev/null
+++ b/packages/react-sdk/src/page-settings-title.tsx
@@ -0,0 +1,55 @@
+import { useEffect, useState } from "react";
+import { isElementRenderedWithReact } from "./page-settings-meta";
+
+type PageSettingsTitleProps = {
+ children: string;
+};
+
+const isServer = typeof window === "undefined";
+
+/**
+ * Title tags are deduplicated on the server using the HTMLRewriter interface.
+ * This is not full deduplication. We simply skip rendering Page Setting title
+ * if it has already been rendered using HeadSlot/HeadTitle.
+ * To prevent React on the client from re-adding the removed title tag, we skip rendering them client-side.
+ * This approach works because React retains server-rendered title tag as long as they are not re-rendered by the client.
+ *
+ * The following component behavior ensures this:
+ * 1. On the server: Render title tag as usual.
+ * 2. On the client: Before rendering, remove any title tag with the same `name` or `property` that were not rendered by Client React,
+ * and then proceed with rendering as usual.
+ */
+export const PageSettingsTitle = (props: PageSettingsTitleProps) => {
+ const [localProps, setLocalProps] = useState<
+ PageSettingsTitleProps | undefined
+ >();
+
+ useEffect(() => {
+ const selector = `head > title`;
+ let allTitles = document.querySelectorAll(selector);
+
+ for (const meta of allTitles) {
+ if (!isElementRenderedWithReact(meta)) {
+ meta.remove();
+ }
+ }
+
+ allTitles = document.querySelectorAll(selector);
+
+ if (allTitles.length === 0) {
+ setLocalProps(props);
+ }
+ }, [props]);
+
+ if (isServer) {
+ return <title {...props} />;
+ }
+
+ if (localProps === undefined) {
+ // This method also works during hydration because React retains server-rendered tags
+ // as long as they are not re-rendered by the client.
+ return;
+ }
+
+ return <title {...localProps} />;
+};
diff --git a/packages/react-sdk/src/runtime.ts b/packages/react-sdk/src/runtime.ts
index a56b0c81fd..c5b06fe65a 100644
--- a/packages/react-sdk/src/runtime.ts
+++ b/packages/react-sdk/src/runtime.ts
@@ -1,7 +1,8 @@
export * from "./context";
export * from "./hook";
export * from "./variable-state";
-export * from "./page-settings-meta";
+export { PageSettingsMeta } from "./page-settings-meta";
+export { PageSettingsTitle } from "./page-settings-title";
/**
* React has issues rendering certain elements, such as errors when a <link> element has children.
diff --git a/packages/sdk-components-react/src/__generated__/head-title.props.ts b/packages/sdk-components-react/src/__generated__/head-title.props.ts
new file mode 100644
index 0000000000..36d0f94ab0
--- /dev/null
+++ b/packages/sdk-components-react/src/__generated__/head-title.props.ts
@@ -0,0 +1,562 @@
+import type { PropMeta } from "@webstudio-is/sdk";
+
+export const props: Record<string, PropMeta> = {
+ about: { required: false, control: "text", type: "string" },
+ accessKey: {
+ required: false,
+ control: "text",
+ type: "string",
+ description: "Keyboard shortcut to activate or add focus to the element.",
+ },
+ "aria-activedescendant": {
+ description:
+ "Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-atomic": {
+ description:
+ "Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-autocomplete": {
+ description:
+ "Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.",
+ required: false,
+ control: "select",
+ type: "string",
+ options: ["list", "none", "inline", "both"],
+ },
+ "aria-braillelabel": {
+ description:
+ "Defines a string value that labels the current element, which is intended to be converted into Braille.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-brailleroledescription": {
+ description:
+ "Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-busy": { required: false, control: "boolean", type: "boolean" },
+ "aria-checked": {
+ description:
+ 'Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.',
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-colcount": {
+ description:
+ "Defines the total number of columns in a table, grid, or treegrid.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-colindex": {
+ description:
+ "Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-colindextext": {
+ description: "Defines a human readable text alternative of aria-colindex.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-colspan": {
+ description:
+ "Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-controls": {
+ description:
+ "Identifies the element (or elements) whose contents or presence are controlled by the current element.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-current": {
+ description:
+ "Indicates the element that represents the current item within a container or set of related elements.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-describedby": {
+ description:
+ "Identifies the element (or elements) that describes the object.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-description": {
+ description:
+ "Defines a string value that describes or annotates the current element.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-details": {
+ description:
+ "Identifies the element that provides a detailed, extended description for the object.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-disabled": {
+ description:
+ "Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-dropeffect": {
+ description:
+ "Indicates what functions can be performed when a dragged object is released on the drop target.",
+ required: false,
+ control: "select",
+ type: "string",
+ options: ["link", "none", "copy", "execute", "move", "popup"],
+ },
+ "aria-errormessage": {
+ description:
+ "Identifies the element that provides an error message for the object.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-expanded": {
+ description:
+ "Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-flowto": {
+ description:
+ "Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,\nallows assistive technology to override the general default of reading in document source order.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-grabbed": {
+ description:
+ 'Indicates an element\'s "grabbed" state in a drag-and-drop operation.',
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-haspopup": {
+ description:
+ "Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-hidden": {
+ description:
+ "Indicates whether the element is exposed to an accessibility API.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-invalid": {
+ description:
+ "Indicates the entered value does not conform to the format expected by the application.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-keyshortcuts": {
+ description:
+ "Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-label": {
+ description:
+ "Provides the accessible name that describes an interactive element if no other accessible name exists, for example in a button that contains an image with no text.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-labelledby": {
+ description:
+ "Identifies the element (or elements) that labels the current element.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-level": {
+ description:
+ "Defines the hierarchical level of an element within a structure.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-live": {
+ description:
+ "Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.",
+ required: false,
+ control: "radio",
+ type: "string",
+ options: ["off", "assertive", "polite"],
+ },
+ "aria-modal": {
+ description: "Indicates whether an element is modal when displayed.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-multiline": {
+ description:
+ "Indicates whether a text box accepts multiple lines of input or only a single line.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-multiselectable": {
+ description:
+ "Indicates that the user may select more than one item from the current selectable descendants.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-orientation": {
+ description:
+ "Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.",
+ required: false,
+ control: "radio",
+ type: "string",
+ options: ["horizontal", "vertical"],
+ },
+ "aria-owns": {
+ description:
+ "Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship\nbetween DOM elements where the DOM hierarchy cannot be used to represent the relationship.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-placeholder": {
+ description:
+ "Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.\nA hint could be a sample value or a brief description of the expected format.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-posinset": {
+ description:
+ "Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-pressed": {
+ description: 'Indicates the current "pressed" state of toggle buttons.',
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-readonly": {
+ description:
+ "Indicates that the element is not editable, but is otherwise operable.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-relevant": {
+ description:
+ "Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.",
+ required: false,
+ control: "select",
+ type: "string",
+ options: [
+ "text",
+ "additions",
+ "additions removals",
+ "additions text",
+ "all",
+ "removals",
+ "removals additions",
+ "removals text",
+ "text additions",
+ "text removals",
+ ],
+ },
+ "aria-required": {
+ description:
+ "Indicates that user input is required on the element before a form may be submitted.",
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-roledescription": {
+ description:
+ "Defines a human-readable, author-localized description for the role of an element.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-rowcount": {
+ description:
+ "Defines the total number of rows in a table, grid, or treegrid.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-rowindex": {
+ description:
+ "Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-rowindextext": {
+ description: "Defines a human readable text alternative of aria-rowindex.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ "aria-rowspan": {
+ description:
+ "Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-selected": {
+ description: 'Indicates the current "selected" state of various widgets.',
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ "aria-setsize": {
+ description:
+ "Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-sort": {
+ description:
+ "Indicates if items in a table or grid are sorted in ascending or descending order.",
+ required: false,
+ control: "select",
+ type: "string",
+ options: ["none", "ascending", "descending", "other"],
+ },
+ "aria-valuemax": {
+ description: "Defines the maximum allowed value for a range widget.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-valuemin": {
+ description: "Defines the minimum allowed value for a range widget.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-valuenow": {
+ description: "Defines the current value for a range widget.",
+ required: false,
+ control: "number",
+ type: "number",
+ },
+ "aria-valuetext": {
+ description:
+ "Defines the human readable text alternative of aria-valuenow for a range widget.",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ autoCapitalize: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Sets whether input is automatically capitalized when entered by user.",
+ },
+ autoCorrect: { required: false, control: "text", type: "string" },
+ autoFocus: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description:
+ "Indicates that an element should be focused on page load, or when its parent dialog is displayed.",
+ },
+ autoSave: { required: false, control: "text", type: "string" },
+ className: { required: false, control: "text", type: "string" },
+ color: {
+ required: false,
+ control: "color",
+ type: "string",
+ description:
+ "This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format. Note: This is a legacy attribute. Please use the CSS color property instead.",
+ },
+ content: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "A value associated with http-equiv orname depending on the context.",
+ },
+ contextMenu: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Defines the ID of a menu element which willserve as the element's context menu.",
+ },
+ datatype: { required: false, control: "text", type: "string" },
+ defaultChecked: { required: false, control: "boolean", type: "boolean" },
+ defaultValue: { required: false, control: "text", type: "string" },
+ dir: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)",
+ },
+ draggable: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description: "Defines whether the element can be dragged.",
+ },
+ hidden: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description:
+ "Prevents rendering of given element, while keeping child elements, e.g. script elements, active.",
+ },
+ id: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Often used with CSS to style a specific element. The value of this attribute must be unique.",
+ },
+ inputMode: {
+ description:
+ "Hints at the type of data that might be entered by the user while editing the element or its contents",
+ required: false,
+ control: "select",
+ type: "string",
+ options: [
+ "search",
+ "text",
+ "none",
+ "tel",
+ "url",
+ "email",
+ "numeric",
+ "decimal",
+ ],
+ },
+ is: {
+ description:
+ "Specify that a standard HTML element should behave like a defined custom built-in element",
+ required: false,
+ control: "text",
+ type: "string",
+ },
+ itemID: { required: false, control: "text", type: "string" },
+ itemProp: { required: false, control: "text", type: "string" },
+ itemRef: { required: false, control: "text", type: "string" },
+ itemScope: { required: false, control: "boolean", type: "boolean" },
+ itemType: { required: false, control: "text", type: "string" },
+ lang: {
+ required: false,
+ control: "text",
+ type: "string",
+ description: "Defines the language used in the element.",
+ },
+ nonce: { required: false, control: "text", type: "string" },
+ prefix: { required: false, control: "text", type: "string" },
+ property: { required: false, control: "text", type: "string" },
+ radioGroup: { required: false, control: "text", type: "string" },
+ rel: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Specifies the relationship of the target object to the link object.",
+ },
+ resource: { required: false, control: "text", type: "string" },
+ results: { required: false, control: "number", type: "number" },
+ rev: { required: false, control: "text", type: "string" },
+ role: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Defines an explicit role for an element for use by assistive technologies.",
+ },
+ security: { required: false, control: "text", type: "string" },
+ slot: {
+ required: false,
+ control: "text",
+ type: "string",
+ description: "Assigns a slot in a shadow DOM shadow tree to an element.",
+ },
+ spellCheck: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ description: "Indicates whether spell checking is allowed for the element.",
+ },
+ suppressContentEditableWarning: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ suppressHydrationWarning: {
+ required: false,
+ control: "boolean",
+ type: "boolean",
+ },
+ tabIndex: {
+ required: false,
+ control: "number",
+ type: "number",
+ description:
+ "Overrides the browser's default tab order and follows the one specified instead.",
+ },
+ title: {
+ required: false,
+ control: "text",
+ type: "string",
+ description:
+ "Text to be displayed in a tooltip when hovering over the element.",
+ },
+ translate: {
+ required: false,
+ control: "radio",
+ type: "string",
+ options: ["yes", "no"],
+ description:
+ "Specify whether an element's attribute values and the values of its text node children are to be translated when the page is localized, or whether to leave them unchanged.",
+ },
+ typeof: { required: false, control: "text", type: "string" },
+ unselectable: {
+ required: false,
+ control: "radio",
+ type: "string",
+ options: ["on", "off"],
+ },
+ vocab: { required: false, control: "text", type: "string" },
+};
diff --git a/packages/sdk-components-react/src/components.ts b/packages/sdk-components-react/src/components.ts
index aa396b3e4e..a12d2af2bc 100644
--- a/packages/sdk-components-react/src/components.ts
+++ b/packages/sdk-components-react/src/components.ts
@@ -41,3 +41,4 @@ export { Option } from "./option";
export { HeadSlot } from "./head-slot";
export { HeadLink } from "./head-link";
export { HeadMeta } from "./head-meta";
+export { HeadTitle } from "./head-title";
diff --git a/packages/sdk-components-react/src/head-slot.template.tsx b/packages/sdk-components-react/src/head-slot.template.tsx
index b6fc69fefa..99260fa9ae 100644
--- a/packages/sdk-components-react/src/head-slot.template.tsx
+++ b/packages/sdk-components-react/src/head-slot.template.tsx
@@ -6,6 +6,7 @@ export const meta: TemplateMeta = {
order: 4,
template: (
<$.HeadSlot>
+ <$.HeadTitle ws:label="Title">Title</$.HeadTitle>
<$.HeadLink ws:label="Link" rel="help" href="/help"></$.HeadLink>
<$.HeadMeta ws:label="Meta" name="keywords" content="SEO"></$.HeadMeta>
</$.HeadSlot>
diff --git a/packages/sdk-components-react/src/head-slot.ws.ts b/packages/sdk-components-react/src/head-slot.ws.ts
index bbb476b1b8..de64b9a108 100644
--- a/packages/sdk-components-react/src/head-slot.ws.ts
+++ b/packages/sdk-components-react/src/head-slot.ws.ts
@@ -18,7 +18,7 @@ export const meta: WsComponentMeta = {
},
{
relation: "child",
- component: { $in: ["HeadLink", "HeadMeta"] },
+ component: { $in: ["HeadLink", "HeadMeta", "HeadTitle"] },
},
],
};
diff --git a/packages/sdk-components-react/src/head-title.tsx b/packages/sdk-components-react/src/head-title.tsx
new file mode 100644
index 0000000000..799b38613f
--- /dev/null
+++ b/packages/sdk-components-react/src/head-title.tsx
@@ -0,0 +1,49 @@
+import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";
+import {
+ forwardRef,
+ type ElementRef,
+ type ComponentProps,
+ useContext,
+} from "react";
+import { XmlNode } from "./xml-node";
+
+export const defaultTag = "title";
+
+const PROPS_ORDER = [] as const;
+
+export const HeadTitle = forwardRef<
+ ElementRef<"div">,
+ ComponentProps<typeof defaultTag>
+>(({ ...props }, ref) => {
+ const { renderer } = useContext(ReactSdkContext);
+
+ const propsSet = new Set([...PROPS_ORDER, ...Object.keys(props)]) as Set<
+ keyof typeof props
+ >;
+
+ const cleanOrderedProps: Record<string, unknown> = {};
+
+ for (const prop of propsSet) {
+ // Boolean check is not a mistake; it excludes empty values.
+ // Empty properties must be excluded because there is no UI to reset them to undefined.
+ if (prop in props && Boolean(props[prop])) {
+ cleanOrderedProps[prop] = props[prop];
+ }
+ }
+
+ if (renderer === undefined) {
+ return <title {...cleanOrderedProps} />;
+ }
+
+ // HTML attributes are case-insensitive, but the convention is to use lowercase
+ const htmlAttributes = Object.fromEntries(
+ Object.entries(cleanOrderedProps).map(([key, value]) => [
+ key?.toLowerCase(),
+ value,
+ ])
+ );
+
+ return <XmlNode tag={defaultTag} {...htmlAttributes} ref={ref} />;
+});
+
+HeadTitle.displayName = "HeadTitle";
diff --git a/packages/sdk-components-react/src/head-title.ws.ts b/packages/sdk-components-react/src/head-title.ws.ts
new file mode 100644
index 0000000000..9663095795
--- /dev/null
+++ b/packages/sdk-components-react/src/head-title.ws.ts
@@ -0,0 +1,22 @@
+import { Link2Icon } from "@webstudio-is/icons/svg";
+import {
+ type WsComponentMeta,
+ type WsComponentPropsMeta,
+} from "@webstudio-is/sdk";
+
+import { props } from "./__generated__/head-title.props";
+
+export const meta: WsComponentMeta = {
+ category: "hidden",
+ icon: Link2Icon,
+ type: "container",
+ stylable: false,
+ constraints: {
+ relation: "parent",
+ component: { $eq: "HeadSlot" },
+ },
+};
+
+export const propsMeta: WsComponentPropsMeta = {
+ props,
+};
diff --git a/packages/sdk-components-react/src/metas.ts b/packages/sdk-components-react/src/metas.ts
index 961ff4c4c8..34450212fa 100644
--- a/packages/sdk-components-react/src/metas.ts
+++ b/packages/sdk-components-react/src/metas.ts
@@ -41,3 +41,4 @@ export { meta as Option } from "./option.ws";
export { meta as HeadSlot } from "./head-slot.ws";
export { meta as HeadLink } from "./head-link.ws";
export { meta as HeadMeta } from "./head-meta.ws";
+export { meta as HeadTitle } from "./head-title.ws";
diff --git a/packages/sdk-components-react/src/props.ts b/packages/sdk-components-react/src/props.ts
index 4e08850784..f9f1309612 100644
--- a/packages/sdk-components-react/src/props.ts
+++ b/packages/sdk-components-react/src/props.ts
@@ -41,3 +41,4 @@ export { propsMeta as Option } from "./option.ws";
export { propsMeta as HeadSlot } from "./head-slot.ws";
export { propsMeta as HeadLink } from "./head-link.ws";
export { propsMeta as HeadMeta } from "./head-meta.ws";
+export { propsMeta as HeadTitle } from "./head-title.ws";