Skip to content

Commit fc512bd

Browse files
committed
fix: turn off js on homepage
1 parent d19bd17 commit fc512bd

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

website/app/root.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ScrollRestoration,
88
useCatch,
99
useLoaderData,
10+
useMatches,
1011
} from 'remix';
1112
import type { LinksFunction } from 'remix';
1213
import tailwind from './styles/tailwind.css';
@@ -113,7 +114,10 @@ export function CatchBoundary(): JSX.Element {
113114

114115
function Document({ children, title }: { children: React.ReactNode; title?: string }) {
115116
const location = useLocation();
117+
const matches = useMatches();
116118

119+
// If at least one route wants to hydrate, this will return true
120+
const includeScripts = matches.some(match => match.handle?.hydrate);
117121
return (
118122
<html lang="en">
119123
<head>
@@ -139,7 +143,7 @@ function Document({ children, title }: { children: React.ReactNode; title?: stri
139143
/>
140144
{children}
141145
{location.pathname !== '/preview' && <ScrollRestoration />}
142-
<Scripts />
146+
{includeScripts ? <Scripts /> : null}
143147
{process.env.NODE_ENV === 'development' && <LiveReload />}
144148
</body>
145149
</html>

website/app/routes/$owner.$repo.$.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { Head } from '~/components/Head';
1919
import { getSocialImage } from '~/utils';
2020
import codeHikeStyles from '@code-hike/mdx/dist/index.css';
2121

22+
export const handle = { hydrate: true };
23+
2224
//@ts-ignore
2325
export function headers({ loaderHeaders }) {
2426
return {

website/app/routes/preview.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import extraStyles from '../styles/extra-styles.css';
1010
import { LandingPage } from '../components/PreviewLandingPage';
1111
import Documentation from '~/components/Documentation';
1212

13+
export const handle = { hydrate: true };
14+
1315
export function headers(): Record<string, string> {
1416
return {
1517
'docs-page-preview': 'true',

0 commit comments

Comments
 (0)