Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sitemap
Browse files Browse the repository at this point in the history
istarkov committed Nov 4, 2024
1 parent e29ceec commit b0b1fe7
Showing 2 changed files with 6 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
// typecheck
arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;

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

// Xml is wrapped with <svg> to prevent React from hoisting elements like <title>, <meta>, and <link> out of their intended scope during rendering.
// More details: https://github.com/facebook/react/blob/7c8e5e7ab8bb63de911637892392c5efd8ce1d0f/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js#L3083
text = text.replace(/^<svg>/g, "").replace(/<\/svg>$/g, "");

return new Response(`<?xml version="1.0" encoding="UTF-8"?>\n${text}`, {
headers: { "Content-Type": "application/xml" },
});

0 comments on commit b0b1fe7

Please sign in to comment.