diff --git a/src/components/Card.tsx b/src/components/Card.tsx index c5c7b4c..bdffc76 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -9,6 +9,24 @@ interface Props { } export default function Card({ title, content, id, downloads }: Props) { + function download(path: URL, fileName = 'file') { + fetch(path) + .then((response) => response.blob()) + .then((blob) => { + const url = window.URL.createObjectURL(new Blob([blob])) + + const link = document.createElement('a') + link.href = url + link.download = fileName + + document.body.appendChild(link) + + link.click() + + link.parentNode?.removeChild(link) + }) + } + return (