feat: static generation

This commit is contained in:
ner committed 2024-11-04 12:35:39 +02:00
1 parent 99255f4f13
commit 25866b9eb9
12 files changed
+50 -66

No files matched your search

+2
View File
@@ -19,4 +19,6 @@ const Random = () => {
);
};
export const revalidate = 1;
export default Random;
+2
View File
@@ -24,4 +24,6 @@ const Popular = () => {
);
};
export const revalidate = 3600;
export default Popular;
+2
View File
@@ -24,4 +24,6 @@ const Top = () => {
);
};
export const revalidate = 3600;
export default Top;
+3 -5
View File
@@ -23,12 +23,10 @@ export const viewport: Viewport = {
const font = Jost({ subsets: ['latin', 'cyrillic'], weight: ['400'] });
const RootLayout = ({ children }: { children: ReactNode }) => {
const theme = cookies().get('theme')?.value as Theme;
return (
<html lang='en' data-mode={theme}>
<html lang='en' suppressHydrationWarning>
<head>
<meta name='theme-color' content={theme === 'dark' ? 'hsl(222.2 84% 4.9%)' : 'white'} />
{/*<meta name='theme-color' content={theme === 'dark' ? 'hsl(222.2 84% 4.9%)' : 'white'} />*/}
<link
rel='icon'
@@ -67,7 +65,7 @@ const RootLayout = ({ children }: { children: ReactNode }) => {
<meta property='og:image' content={`${SITE_URL}/apple-touch-icon.png`} />
</head>
<body className={font.className}>
<Providers theme={theme}>
<Providers>
<Header className='sticky top-0 z-20' />
<main className='container'>{children}</main>
</Providers>
@@ -1,23 +1,36 @@
'use client';
import { Moon, Sun } from 'lucide-react';
import { useTheme } from 'next-themes';
import { Button } from '@/components/ui/button';
import useTheme from '@/hooks/useTheme';
const ThemeToggle = () => {
const [theme, setTheme] = useTheme();
const { setTheme } = useTheme();
return (
<>
<Button
aria-label='Toggle theme'
variant='ghost'
size='icon'
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
title={`Set ${theme === 'dark' ? 'light' : 'dark'} theme`}
onClick={() => setTheme('light')}
className='hidden dark:flex'
title='Set light theme'
>
{theme === 'light' ? <Moon size={19} /> : <Sun size={19} />}
<Sun size={19} />
</Button>
<Button
aria-label='Toggle theme'
variant='ghost'
size='icon'
onClick={() => setTheme('dark')}
className='flex dark:hidden'
title='Set dark theme'
>
<Moon size={19} />
</Button>
</>
);
};
@@ -6,7 +6,6 @@ import { useRouter } from 'next/navigation';
import { Button } from '@/components/ui/button';
import ButtonsGroup from '@/components/ui/buttons-group';
import useShowState, { useMutateShowState } from '@/hooks/useShowState';
import useTheme from '@/hooks/useTheme';
import { cn } from '@/lib/utils';
interface Props {
@@ -18,8 +17,6 @@ interface Props {
const Actions = ({ onClose, show, className }: Props) => {
const router = useRouter();
const [theme] = useTheme();
const state = useShowState({ showId: show.id, showType: show.type });
const toggle = useMutateShowState(show);
@@ -63,10 +60,7 @@ const Actions = ({ onClose, show, className }: Props) => {
</Button>
<Button
aria-label='Watch'
className={cn('hover:shadow-lg hover:shadow-red-600/60 duration-200 transition-all hover:bg-red-600', {
'bg-red-600': theme === 'light',
'bg-red-700': theme === 'dark'
})}
className='bg-red-600 transition-all duration-200 hover:bg-red-600 hover:shadow-lg hover:shadow-red-600/60 dark:bg-red-700'
variant='destructive'
onClick={async () => {
const showTorrentsModal = (await import('../Torrents')).default;
-9
View File
@@ -1,9 +0,0 @@
'use client';
import { useContext } from 'react';
import { ThemeContext } from '@/providers/Theme';
const useTheme = () => useContext(ThemeContext);
export default useTheme;
+17
View File
@@ -27,6 +27,7 @@
"media-icons": "^1.1.5",
"next": "^14.2.7",
"next-pwa": "^5.6.0",
"next-themes": "^0.4.1",
"parse-torrent": "^11.0.17",
"react": "^18.3.1",
"react-dom": "^18.3.1",
@@ -9240,6 +9241,16 @@
"next": ">=9.0.0"
}
},
"node_modules/next-themes": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.1.tgz",
"integrity": "sha512-xD3cn42n0f1DFCAOlxJlrGPog+WdhWHObgJ+LTM7J5Bff/uBuq4vn/okSSao7puz7yBLcrELLOQ7F1/9hwycyQ==",
"license": "MIT",
"peerDependencies": {
"react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc"
}
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
@@ -18257,6 +18268,12 @@
"workbox-window": "^6.5.4"
}
},
"next-themes": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.1.tgz",
"integrity": "sha512-xD3cn42n0f1DFCAOlxJlrGPog+WdhWHObgJ+LTM7J5Bff/uBuq4vn/okSSao7puz7yBLcrELLOQ7F1/9hwycyQ==",
"requires": {}
},
"node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
+1
View File
@@ -31,6 +31,7 @@
"media-icons": "^1.1.5",
"next": "^14.2.7",
"next-pwa": "^5.6.0",
"next-themes": "^0.4.1",
"parse-torrent": "^11.0.17",
"react": "^18.3.1",
"react-dom": "^18.3.1",
-34
View File
@@ -1,34 +0,0 @@
import { createContext, Dispatch, FC, ReactNode, SetStateAction, useEffect, useState } from 'react';
import Cookies from 'js-cookie';
export const ThemeContext = createContext<[Theme, Dispatch<SetStateAction<Theme>>]>([
Cookies.get('theme') as Theme,
() => null
]);
interface Props {
children: ReactNode;
theme?: Theme;
}
const Provider: FC<Props> = ({ children, theme: initialTheme }) => {
const state = useState<Theme>((Cookies.get('theme') || initialTheme) as Theme);
const [theme, setTheme] = state;
useEffect(() => {
if (!theme) {
return setTheme(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
}
document.documentElement.setAttribute('data-mode', theme);
document
.querySelector('meta[name="theme-color"]')
?.setAttribute('content', theme === 'dark' ? 'hsl(222.2 84% 4.9%)' : 'white');
Cookies.set('theme', theme);
}, [theme, setTheme]);
return <ThemeContext.Provider value={state}>{children}</ThemeContext.Provider>;
};
export default Provider;
+3 -5
View File
@@ -5,24 +5,22 @@ import ModalContainer from 'react-modal-promise';
import { QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
import { ThemeProvider } from 'next-themes';
import { Toaster } from '@/components/ui/toaster';
import getQueryClient from '@/lib/queryClient';
import ThemeProvider from './Theme';
interface Props {
children: ReactNode;
theme?: Theme;
}
const Providers: FC<Props> = ({ children, theme }) => {
const Providers: FC<Props> = ({ children }) => {
const queryClient = getQueryClient();
return (
<QueryClientProvider client={queryClient}>
<ReactQueryStreamedHydration>
<ThemeProvider theme={theme}>{children}</ThemeProvider>
<ThemeProvider attribute='data-mode'>{children}</ThemeProvider>
</ReactQueryStreamedHydration>
<ModalContainer exitTimeout={0} enterTimeout={0} />
<Toaster />
+1 -1
View File
@@ -1 +1 @@
if(!self.define){let e,s={};const i=(i,c)=>(i=new URL(i+".js",c).href,s[i]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()})).then((()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e})));self.define=(c,n)=>{const a=e||("document"in self?document.currentScript.src:"")||location.href;if(s[a])return;let t={};const r=e=>i(e,a),f={module:{uri:a},exports:t,require:r};s[a]=Promise.all(c.map((e=>f[e]||r(e)))).then((e=>(n(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"78a5f6c961ddc5045cce04f87f3f4bcd"},{url:"/_next/static/AiKO7VYci0SrezPfksdSC/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/AiKO7VYci0SrezPfksdSC/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.431d65c3703a61be.js",revision:"431d65c3703a61be"},{url:"/_next/static/chunks/209-0e9125d7ac790983.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/67-95ca9a279b250d8e.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/674-7c487cb45ac8eb18.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/777-8b16504cf2d037d6.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.a4d728274961d42c.js",revision:"a4d728274961d42c"},{url:"/_next/static/chunks/app/(site)/favorites/page-773b03aaf7689724.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/(site)/page-c718500a5dae0d58.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/(site)/popular/page-e8f29f76ecb6ecc2.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/(site)/similar/page-a1283aca0d4b91f2.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/(site)/starring/page-ece649b9d5f0e576.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/(site)/top/page-3db74c54f17cd8eb.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/(site)/watch-list/page-d1af0327cd0c9414.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/app/layout-232c5acf877aac0b.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/main-a339d49e77d6dbd3.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-134a99c33ababfb0.js",revision:"AiKO7VYci0SrezPfksdSC"},{url:"/_next/static/css/08f675b4c37cc586.css",revision:"08f675b4c37cc586"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285bf54b5"},{url:"/_next/static/media/dd843ebd3ff03195-s.p.woff2",revision:"333341dc4117f45b7fcee6b5223a56db"},{url:"/_next/static/media/e9ecf55e71a874cd-s.woff2",revision:"62348655e2d5baedLine truncated
if(!self.define){let e,s={};const c=(c,n)=>(c=new URL(c+".js",n).href,s[c]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=c,e.onload=s,document.head.appendChild(e)}else e=c,importScripts(c),s()})).then((()=>{let e=s[c];if(!e)throw new Error(`Module ${c} didn’t register its module`);return e})));self.define=(n,i)=>{const a=e||("document"in self?document.currentScript.src:"")||location.href;if(s[a])return;let t={};const r=e=>c(e,a),o={module:{uri:a},exports:t,require:r};s[a]=Promise.all(n.map((e=>o[e]||r(e)))).then((e=>(i(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"6696ebb450df1bf2efcc91350652c211"},{url:"/_next/static/Cs1RrcyABXKLNFDVKsycK/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/Cs1RrcyABXKLNFDVKsycK/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.431d65c3703a61be.js",revision:"431d65c3703a61be"},{url:"/_next/static/chunks/209-0e9125d7ac790983.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/620-ce207e9956199681.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/67-aa69306617e341d2.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/777-8b16504cf2d037d6.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.a4d728274961d42c.js",revision:"a4d728274961d42c"},{url:"/_next/static/chunks/app/(site)/favorites/page-773b03aaf7689724.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/(site)/page-c718500a5dae0d58.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/(site)/popular/page-e8f29f76ecb6ecc2.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/(site)/similar/page-a1283aca0d4b91f2.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/(site)/starring/page-ece649b9d5f0e576.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/(site)/top/page-3db74c54f17cd8eb.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/(site)/watch-list/page-d1af0327cd0c9414.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/app/layout-4932543f69ea791a.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/main-a339d49e77d6dbd3.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-134a99c33ababfb0.js",revision:"Cs1RrcyABXKLNFDVKsycK"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/a61ed9eb64fa65b2.css",revision:"a61ed9eb64fa65b2"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285bf54b5"},{url:"/_next/static/media/dd843ebd3ff03195-s.p.woff2",revision:"333341dc4117f45b7fcee6b5223a56db"},{url:"/_next/static/media/e9ecf55e71a874cd-s.woff2",revision:"62348655e2d5baedLine truncated