mirror of
https://github.com/Nezumi-2711/next-gdrive-index.git
synced 2026-09-22 20:01:36 +00:00
34 lines
820 B
TypeScript
34 lines
820 B
TypeScript
import { drive_v3 } from "googleapis";
|
|
import useSWR from "swr";
|
|
import MarkdownRender from "components/utility/MarkdownRender";
|
|
import { createFileId } from "utils/driveHelper";
|
|
import SWRLayout from "components/layout/SWRLayout";
|
|
|
|
type Props = {
|
|
data: drive_v3.Schema$File;
|
|
};
|
|
|
|
export default function TextPreview({ data }: Props) {
|
|
const fileId = createFileId(data);
|
|
const {
|
|
data: swrData,
|
|
error,
|
|
isLoading,
|
|
} = useSWR(`/api/files/${fileId}?download=1`);
|
|
|
|
return (
|
|
<div className='flex w-full items-center justify-center'>
|
|
<SWRLayout
|
|
data={swrData}
|
|
error={error}
|
|
isLoading={isLoading}
|
|
useCard={false}
|
|
>
|
|
<div className={"w-full"}>
|
|
<MarkdownRender content={swrData as string} />
|
|
</div>
|
|
</SWRLayout>
|
|
</div>
|
|
);
|
|
}
|