Files
webstudio/packages/cli/templates/defaults/app/root.tsx
T
Ivan Starkov ef81ccfafd fix: Resolve issue with script tag compilation in self-hosted Project Settings (#3483)
## Description

Corresponding SAAS PR
https://github.com/webstudio-is/webstudio-saas/pull/298
(Must be renamed to "release.staging" on release to allow testing)

closes #3378 

## Steps for reproduction

See fixtures now have working scripts.
Publish see saas supports script and language
https://rewrites.staging.webstudio.is/builder/f30da574-8022-433e-9a15-050792747b6f
.

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-06-05 09:53:43 +03:00

36 lines
881 B
TypeScript

/* eslint-disable @typescript-eslint/ban-ts-comment */
import { Links, Meta, Outlet, useMatches } from "@remix-run/react";
// @todo think about how to make __generated__ typeable
// @ts-ignore
import { CustomCode } from "./__generated__/_index";
const Root = () => {
// Get language from matches
const matches = useMatches();
const lastMatchWithLanguage = matches.findLast((match) => {
// @ts-ignore
const language = match?.data?.pageMeta?.language;
return language != null;
});
// @ts-ignore
const lang = lastMatchWithLanguage?.data?.pageMeta?.language ?? "en";
return (
<html lang={lang}>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
<CustomCode />
</head>
<Outlet />
</html>
);
};
export default Root;