diff --git a/index.html b/index.html
index 4de385a..85cf795 100644
--- a/index.html
+++ b/index.html
@@ -4,13 +4,7 @@
-
-
-
-
Create TanStack App - academic
+ Personal Website
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 (
@@ -24,10 +42,11 @@ export default function Card({ title, content, id, downloads }: Props) {
{downloads.map((e, i) => (
download(e.link, e.filename)}
>
{e.title}
diff --git a/src/types/cards.tsx b/src/types/cards.tsx
index 81152ad..6f4131b 100644
--- a/src/types/cards.tsx
+++ b/src/types/cards.tsx
@@ -1,7 +1,7 @@
export type CardDownloadType = {
title: string
filename: string
- link: string
+ link: URL
}
export type CardType = {