fix: download not working
This commit is contained in:
parent
ce1751c871
commit
05f0f80600
1 changed files with 42 additions and 33 deletions
|
|
@ -10,6 +10,34 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Card({ title, content, id, downloads }: Props) {
|
export default function Card({ title, content, id, downloads }: Props) {
|
||||||
|
return (
|
||||||
|
<div className="bg-[#161718] w-lg p-5 flex flex-col gap-5 rounded-xl self-center">
|
||||||
|
<h1 className="text-white text-2xl font-bold" id={id?.toString()}>
|
||||||
|
<Mdown>{title}</Mdown>
|
||||||
|
</h1>
|
||||||
|
<div className=" flex flex-col space-y-1 text-[#9e9b97]">
|
||||||
|
<Mdown>{content}</Mdown>
|
||||||
|
</div>
|
||||||
|
{downloads != null ? (
|
||||||
|
<details className="text-[#9e9b97]">
|
||||||
|
<summary>Téléchargments</summary>
|
||||||
|
<ol className="list-disc list-inside pl-5">
|
||||||
|
{downloads.map((e, i) => (
|
||||||
|
<Download e={e} i={i} />
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
</details>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DownloadProps {
|
||||||
|
e: CardDownloadType
|
||||||
|
i: number
|
||||||
|
}
|
||||||
|
|
||||||
|
function Download({ e, i }: DownloadProps) {
|
||||||
const [isDownloading, setIsDownloading] = useState(false)
|
const [isDownloading, setIsDownloading] = useState(false)
|
||||||
|
|
||||||
function download(path: URL, fileName = 'file') {
|
function download(path: URL, fileName = 'file') {
|
||||||
|
|
@ -37,38 +65,19 @@ export default function Card({ title, content, id, downloads }: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-[#161718] w-lg p-5 flex flex-col gap-5 rounded-xl self-center">
|
<li>
|
||||||
<h1 className="text-white text-2xl font-bold" id={id?.toString()}>
|
<a
|
||||||
<Mdown>{title}</Mdown>
|
key={i}
|
||||||
</h1>
|
className={
|
||||||
<div className=" flex flex-col space-y-1 text-[#9e9b97]">
|
isDownloading
|
||||||
<Mdown>{content}</Mdown>
|
? 'text-gray-600 underline cursor-wait'
|
||||||
</div>
|
: 'text-sky-600 underline cursor-pointer'
|
||||||
{downloads != null ? (
|
}
|
||||||
<details className="text-[#9e9b97]">
|
onClick={() => download(e.link, e.filename)}
|
||||||
<summary>Téléchargments</summary>
|
>
|
||||||
<ol className="list-disc list-inside pl-5">
|
{isDownloading ? '[Téléchargement en cours ...] ' : null}{' '}
|
||||||
{downloads.map((e, i) => (
|
{e.title}
|
||||||
<li>
|
</a>
|
||||||
<a
|
</li>
|
||||||
key={i}
|
|
||||||
className={
|
|
||||||
isDownloading
|
|
||||||
? 'text-gray-600 underline cursor-wait'
|
|
||||||
: 'text-sky-600 underline cursor-pointer'
|
|
||||||
}
|
|
||||||
onClick={() => download(e.link, e.filename)}
|
|
||||||
>
|
|
||||||
{isDownloading
|
|
||||||
? '[Téléchargement en cours ...] '
|
|
||||||
: null}{' '}
|
|
||||||
{e.title}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ol>
|
|
||||||
</details>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue