mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
chore: external script work and comments
This commit is contained in:
parent
a129e737d2
commit
4fa8cd89e2
@ -2,7 +2,7 @@ import type { AppProps } from "next/app";
|
|||||||
import { SessionProvider } from "next-auth/react";
|
import { SessionProvider } from "next-auth/react";
|
||||||
import Script, { ScriptProps } from "next/script";
|
import Script, { ScriptProps } from "next/script";
|
||||||
import "../styles/globals.css";
|
import "../styles/globals.css";
|
||||||
import "../styles/dark.css";
|
import "../styles/dark.css"; // TODO: Setup themeing the React way
|
||||||
|
|
||||||
// TODO: Do these scripts need to be on every page?
|
// TODO: Do these scripts need to be on every page?
|
||||||
|
|
||||||
@ -10,27 +10,32 @@ type ClientOnlyScriptProps = {
|
|||||||
src: string;
|
src: string;
|
||||||
} & ScriptProps;
|
} & ScriptProps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This wraps next/script and returns early if `window` is not detected
|
||||||
|
* due to next using SSR
|
||||||
|
*/
|
||||||
const ClientOnlyScript = ({ src, ...props }: ClientOnlyScriptProps) => {
|
const ClientOnlyScript = ({ src, ...props }: ClientOnlyScriptProps) => {
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window === "undefined") {
|
||||||
return <Script src={src} {...props} />;
|
return;
|
||||||
}
|
}
|
||||||
|
return <Script src={src} {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
|
function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Script
|
{/* <Script
|
||||||
strategy="lazyOnload"
|
strategy="lazyOnload"
|
||||||
src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"
|
src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"
|
||||||
/>
|
/> */}
|
||||||
<Script
|
<Script
|
||||||
onError={(e) => console.log(`Error loading script.js: ${e}`)}
|
onError={(e) => console.log(`Error loading script.js: ${e}`)}
|
||||||
strategy="lazyOnload"
|
strategy="lazyOnload"
|
||||||
src="/js/script.js"
|
src="/js/script.js"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/** TODO: Detect casting before loading this */}
|
{/** TODO: Detect casting before loading this? */}
|
||||||
<ClientOnlyScript strategy="lazyOnload" src="cast-videos.js" />
|
{/* <ClientOnlyScript strategy="lazyOnload" src="/js/cast-videos.js" /> */}
|
||||||
|
|
||||||
<SessionProvider session={session}>
|
<SessionProvider session={session}>
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
|
Loading…
Reference in New Issue
Block a user