mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Detect Rocket Loader and advert about it on docs (#295)
This commit is contained in:
@@ -6,6 +6,7 @@ import * as ReactDOM from 'react-dom';
|
||||
import { AdminToolbar } from '@/components/AdminToolbar';
|
||||
import { CookiesToast } from '@/components/Cookies';
|
||||
import { LoadIntegrations } from '@/components/Integrations';
|
||||
import { RocketLoaderDetector } from '@/components/RocketLoaderDetector';
|
||||
import { SpaceLayout } from '@/components/SpaceLayout';
|
||||
import { buildVersion } from '@/lib/build';
|
||||
import { getContentSecurityPolicyNonce } from '@/lib/csp';
|
||||
@@ -76,6 +77,8 @@ export default async function ContentLayout(props: { children: React.ReactNode }
|
||||
</React.Suspense>
|
||||
) : null}
|
||||
|
||||
<RocketLoaderDetector />
|
||||
|
||||
<AdminToolbar space={space} content={content} />
|
||||
</ClientContexts>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export function RocketLoaderDetector() {
|
||||
return (
|
||||
<script data-cfasync="false">
|
||||
{`
|
||||
if (Array.from(document.scripts).find(script => script.src.includes('rocket-loader.min.js'))) {
|
||||
document.getElementById('gitbook-main-content').innerHTML = \`
|
||||
<div class="p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400 max-w-screen-lg mt-10 mx-auto" role="alert">
|
||||
<strong>Error in site configuration:</strong>
|
||||
It looks like \${window.location.hostname} has been incorrectly configured in Cloudflare. This may lead to unexpected behavior or issues with the page loading. If you are the owner of this site, please refer to <a href="https://docs.gitbook.com/published-documentation/custom-domain/configure-dns#are-you-using-cloudflare">GitBook's documentation</a> for steps to fix the problem.
|
||||
</div>
|
||||
\`;
|
||||
}
|
||||
`}
|
||||
</script>
|
||||
);
|
||||
}
|
||||
@@ -96,7 +96,9 @@ export function SpaceLayout(props: {
|
||||
}
|
||||
withHeaderOffset={withTopHeader}
|
||||
/>
|
||||
<div className={tcls('flex-1', 'flex', 'flex-col')}>{children}</div>
|
||||
<div id="gitbook-main-content" className={tcls('flex-1', 'flex', 'flex-col')}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{customization.themes.toggeable ||
|
||||
|
||||
Reference in New Issue
Block a user