diff --git a/src/components/Card.tsx b/src/components/Card.tsx index 2ea9502..54e73ae 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -1,5 +1,6 @@ import type { CardDownloadType } from '@/types/cards' import Mdown from './Mdown' +import { useState } from 'react' interface Props { title: string @@ -9,7 +10,13 @@ interface Props { } export default function Card({ title, content, id, downloads }: Props) { + const [isDownloading, setIsDownloading] = useState(false) + function download(path: URL, fileName = 'file') { + if (isDownloading) { + return + } + setIsDownloading(true) fetch(path) .then((response) => response.blob()) .then((blob) => { @@ -24,6 +31,8 @@ export default function Card({ title, content, id, downloads }: Props) { link.click() link.parentNode?.removeChild(link) + + setIsDownloading(false) }) } @@ -43,9 +52,16 @@ export default function Card({ title, content, id, downloads }: Props) {