Skip to content

Commit b0b1fe7

Browse files
committed
Fix sitemap
1 parent e29ceec commit b0b1fe7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

fixtures/webstudio-custom-template/app/__generated__/[sitemap.xml]._index.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-custom-template/app/routes/[sitemap.xml]._index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
6060
// typecheck
6161
arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;
6262

63-
const text = renderToString(
63+
let text = renderToString(
6464
<ReactSdkContext.Provider
6565
value={{
6666
imageLoader,
@@ -73,6 +73,10 @@ export const loader = async (arg: LoaderFunctionArgs) => {
7373
</ReactSdkContext.Provider>
7474
);
7575

76+
// Xml is wrapped with <svg> to prevent React from hoisting elements like <title>, <meta>, and <link> out of their intended scope during rendering.
77+
// More details: https://github.com/facebook/react/blob/7c8e5e7ab8bb63de911637892392c5efd8ce1d0f/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js#L3083
78+
text = text.replace(/^<svg>/g, "").replace(/<\/svg>$/g, "");
79+
7680
return new Response(`<?xml version="1.0" encoding="UTF-8"?>\n${text}`, {
7781
headers: { "Content-Type": "application/xml" },
7882
});

0 commit comments

Comments
 (0)