From 21d22ab5e815b7972497aa6b4ed6379f8b73eba4 Mon Sep 17 00:00:00 2001 From: Alzalia Date: Sat, 6 Sep 2025 19:09:49 +0200 Subject: [PATCH 1/4] fix: download not working --- src/components/Card.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/Card.tsx b/src/components/Card.tsx index bdffc76..2ea9502 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -42,9 +42,7 @@ export default function Card({ title, content, id, downloads }: Props) { {downloads.map((e, i) => (
  • download(e.link, e.filename)} > From ce1751c871a2cef53534a351bbe3f5ef5e2e6336 Mon Sep 17 00:00:00 2001 From: Alzalia Date: Sat, 6 Sep 2025 21:20:48 +0200 Subject: [PATCH 2/4] fix: download not working --- src/components/Card.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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) {
  • download(e.link, e.filename)} > + {isDownloading + ? '[Téléchargement en cours ...] ' + : null}{' '} {e.title}
  • From 05f0f80600474a8adffc0ce9f7d4b9b0f19c916e Mon Sep 17 00:00:00 2001 From: Alzalia Date: Sat, 6 Sep 2025 21:26:52 +0200 Subject: [PATCH 3/4] fix: download not working --- src/components/Card.tsx | 75 +++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/src/components/Card.tsx b/src/components/Card.tsx index 54e73ae..d0f94ca 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -10,6 +10,34 @@ interface Props { } export default function Card({ title, content, id, downloads }: Props) { + return ( +
    +

    + {title} +

    +
    + {content} +
    + {downloads != null ? ( +
    + Téléchargments +
      + {downloads.map((e, i) => ( + + ))} +
    +
    + ) : null} +
    + ) +} + +interface DownloadProps { + e: CardDownloadType + i: number +} + +function Download({ e, i }: DownloadProps) { const [isDownloading, setIsDownloading] = useState(false) function download(path: URL, fileName = 'file') { @@ -37,38 +65,19 @@ export default function Card({ title, content, id, downloads }: Props) { } return ( -
    -

    - {title} -

    -
    - {content} -
    - {downloads != null ? ( -
    - Téléchargments -
      - {downloads.map((e, i) => ( -
    1. - download(e.link, e.filename)} - > - {isDownloading - ? '[Téléchargement en cours ...] ' - : null}{' '} - {e.title} - -
    2. - ))} -
    -
    - ) : null} -
    +
  • + download(e.link, e.filename)} + > + {isDownloading ? '[Téléchargement en cours ...] ' : null}{' '} + {e.title} + +
  • ) } From 890944ab64e00883d054a5722dfddca49e556d86 Mon Sep 17 00:00:00 2001 From: Alzalia Date: Sun, 21 Sep 2025 22:49:24 +0200 Subject: [PATCH 4/4] fix: made page better --- src/components/Card.tsx | 2 +- src/components/Mdown.tsx | 15 ++++++++++++++- src/routes/index.tsx | 2 +- src/routes/lessons/$lessonName.tsx | 2 +- src/routes/lessons/index.tsx | 2 +- src/routes/projects/index.tsx | 2 +- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/Card.tsx b/src/components/Card.tsx index d0f94ca..82f7615 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -11,7 +11,7 @@ interface Props { export default function Card({ title, content, id, downloads }: Props) { return ( -
    +

    {title}

    diff --git a/src/components/Mdown.tsx b/src/components/Mdown.tsx index cab339a..8dd4979 100644 --- a/src/components/Mdown.tsx +++ b/src/components/Mdown.tsx @@ -22,9 +22,22 @@ export default function Mdown({ children }: Props) { const { node, ...rest } = props return
  • }, + p(props) { + const { node, ...rest } = props + return

    + }, + code(props) { + const { node, ...rest } = props + return ( + + ) + }, a(props) { const { node, ...rest } = props - const classes = 'text-sky-600 underline' + const classes = 'text-sky-700 underline' if (rest.href?.startsWith('dl:')) { let parts = rest.href.split('/') return ( diff --git a/src/routes/index.tsx b/src/routes/index.tsx index e93f99c..d720a17 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -31,7 +31,7 @@ function App() { return (

    -
    +

    {data.title}

    diff --git a/src/routes/lessons/$lessonName.tsx b/src/routes/lessons/$lessonName.tsx index 41ec497..efabaaf 100644 --- a/src/routes/lessons/$lessonName.tsx +++ b/src/routes/lessons/$lessonName.tsx @@ -44,7 +44,7 @@ export default function Projects() { return (
    -
    +

    {data.title}

    diff --git a/src/routes/lessons/index.tsx b/src/routes/lessons/index.tsx index 0eb6a72..2baf91a 100644 --- a/src/routes/lessons/index.tsx +++ b/src/routes/lessons/index.tsx @@ -31,7 +31,7 @@ export default function Projects() { return (
    -
    +

    {data.title}

    diff --git a/src/routes/projects/index.tsx b/src/routes/projects/index.tsx index 941e840..c34a702 100644 --- a/src/routes/projects/index.tsx +++ b/src/routes/projects/index.tsx @@ -31,7 +31,7 @@ export default function Projects() { return (
    -
    +

    {data.title}