mirror of
https://github.com/pheralb/svgl.git
synced 2025-04-07 16:58:12 +08:00
30 lines
678 B
TypeScript
30 lines
678 B
TypeScript
import Head from "next/head";
|
|
import { useRouter } from "next/router";
|
|
import useSWR from "swr";
|
|
|
|
import Show from "@/animations/show";
|
|
import { getSvgById } from "@/services";
|
|
import Loading from "@/components/loading";
|
|
import SVGInfo from "@/components/svgInfo";
|
|
|
|
export default function Icon() {
|
|
const router = useRouter();
|
|
const { data, error } = useSWR(
|
|
() => router.query.id && `${getSvgById}${router.query.id}`
|
|
);
|
|
|
|
if (error) router.push("/404");
|
|
if (!data) return <Loading text="Loading..." />;
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>{data.title} - svgl</title>
|
|
</Head>
|
|
<Show>
|
|
<SVGInfo {...data} />
|
|
</Show>
|
|
</>
|
|
);
|
|
}
|