feat: add global 404 page

This commit is contained in:
xfy
2025-05-19 20:09:20 +08:00
parent 39089feea8
commit 7b6bf536ea
10 changed files with 48 additions and 13 deletions

View File

@ -1,5 +1,5 @@
NEXT_PUBLIC_GITHUB_API=
NEXT_PUBLIC_GISCUS_CATEGORY_ID=
NEXT_PUBLIC_GISCUS_REPO_ID=
# NEXT_PUBLIC_GITHUB_API=
# NEXT_PUBLIC_GISCUS_CATEGORY_ID=
# NEXT_PUBLIC_GISCUS_REPO_ID=
NEXT_PUBLIC_ALGOLIA_SEARCH_ADMIN_KEY=
NEXT_PUBLIC_ALGOLIA_APP_ID=

View File

@ -10,14 +10,18 @@ const GlobalError = ({
error: Error & { digest?: string };
reset: () => void;
}) => {
console.error(error);
return (
<html>
<body
className={clsx('w-full h-dvh flex', 'justify-center items-center')}
>
<div>
<h2 className="text-xl">Something went wrong! ( OωO)</h2>
<Button onClick={() => reset()}>Try again</Button>
<h2 className="text-xl mb-1">Something went wrong! ( OωO)</h2>
<Button onClick={() => reset()} className="cursor-pointer">
Try again
</Button>
</div>
</body>
</html>

15
app/not-found.tsx Normal file
View File

@ -0,0 +1,15 @@
import Button from 'components/rua/button';
import Link from 'next/link';
export default function NotFound() {
return (
<main className="flex-1 w-full max-w-4xl mx-auto flex items-center justify-center">
<div>
<h2 className="text-xl mb-1"> ( ||)</h2>
<Link href="/">
<Button className="cursor-pointer">Home</Button>
</Link>
</div>
</main>
);
}

View File

@ -16,7 +16,6 @@ const PostToc = dynamic(() => import('components/post/post-toc'));
const PostCommnetLine = dynamic(
() => import('components/post/post-commnet-line'),
);
const PostComment = dynamic(() => import('components/post/post-comment'));
export async function generateStaticParams() {
return await allPostsPath();

View File

@ -41,6 +41,7 @@ const BackToTop = () => {
'lg:right-8 lg:bottom-8',
'transition-all duration-300',
showTop ? 'visible scale-100' : 'invisible scale-0',
'cursor-pointer',
)}
>
<FiChevronUp className="w-6 h-6" />

View File

@ -14,11 +14,11 @@ const CatModel = () => {
const camera = useThree((state) => state.camera);
const gltf = useLoader(
GLTFLoader,
'./models/just_a_hungry_cat/modelDraco.gltf',
'/models/just_a_hungry_cat/modelDraco.gltf',
(loader) => {
toggleLoading(true);
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('./libs/draco/');
dracoLoader.setDecoderPath('/libs/draco/');
loader.setDRACOLoader(dracoLoader);
},
);

View File

@ -41,11 +41,11 @@ const CloudModel = () => {
const gltf = useLoader(
GLTFLoader,
'./models/cloud_station/modelDraco.gltf',
'/models/cloud_station/modelDraco.gltf',
(loader) => {
toggleLoading(true);
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('./libs/draco/');
dracoLoader.setDecoderPath('/libs/draco/');
loader.setDRACOLoader(dracoLoader);
},
);

View File

@ -6,7 +6,7 @@ import { GistData, GistsFile, PageKeys, PageSize } from 'types';
const password = process.env.NEXT_PUBLIC_GITHUB_API;
const host = process.env.NEXT_PUBLIC_GISTS_HOST ?? 'https://api.github.com';
if (!password) throw new Error('No GitHub token detected.');
// if (!password) throw new Error('No GitHub token detected.');
const MyOctokit = Octokit.plugin(restEndpointMethods);
const octokit = new MyOctokit({
auth: password,

12
lib/image.ts Normal file
View File

@ -0,0 +1,12 @@
// [TODO]
export default function imageProcess({
src,
width,
quality,
}: {
src: string;
width: number;
quality?: number;
}) {
return `/${src}`;
}

View File

@ -15,8 +15,9 @@ const fileLoaderPathUrl = new URL(fileLoaderPath, import.meta.url).href;
*/
const nextConfig = {
reactStrictMode: true,
// swcMinify: true,
output: 'standalone',
// output: 'standalone',
output: 'export',
trailingSlash: true,
allowedDevOrigins: [
'local-origin.dev',
'*.local-origin.dev',
@ -29,6 +30,9 @@ const nextConfig = {
hostname: '**',
},
],
unoptimized: true,
loader: 'custom',
loaderFile: './lib/image.ts',
},
experimental: {
webpackBuildWorker: true,