Compare commits

...

4 commits

Author SHA1 Message Date
890944ab64 fix: made page better 2025-09-21 22:49:24 +02:00
05f0f80600 fix: download not working 2025-09-06 21:26:52 +02:00
ce1751c871 fix: download not working 2025-09-06 21:20:48 +02:00
21d22ab5e8 fix: download not working 2025-09-06 19:09:49 +02:00
6 changed files with 69 additions and 33 deletions

View file

@ -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,41 @@ interface Props {
}
export default function Card({ title, content, id, downloads }: Props) {
return (
<div className="bg-[#161718] w-xl max-w-4/5 p-5 flex flex-col gap-5 rounded-xl self-center hover:shadow-xl/20 hover:shadow-white transition-shadow mb-5">
<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)
function download(path: URL, fileName = 'file') {
if (isDownloading) {
return
}
setIsDownloading(true)
fetch(path)
.then((response) => response.blob())
.then((blob) => {
@ -24,37 +59,25 @@ export default function Card({ title, content, id, downloads }: Props) {
link.click()
link.parentNode?.removeChild(link)
setIsDownloading(false)
})
}
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) => (
<li>
<a
href={e.link.toString()}
key={i}
download={e.filename}
className="text-sky-600 underline"
onClick={() => download(e.link, e.filename)}
>
{e.title}
</a>
</li>
))}
</ol>
</details>
) : null}
</div>
<li>
<a
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>
)
}

View file

@ -22,9 +22,22 @@ export default function Mdown({ children }: Props) {
const { node, ...rest } = props
return <li className="pl-5" {...rest} />
},
p(props) {
const { node, ...rest } = props
return <p className="text-justify" {...rest} />
},
code(props) {
const { node, ...rest } = props
return (
<code
className="bg-gray-900 border-gray-600 border rounded-sm p-1 text-sm"
{...rest}
/>
)
},
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 (

View file

@ -31,7 +31,7 @@ function App() {
return (
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
<div className="flex flex-col gap-5 pt-10">
<div className="flex flex-col pt-10">
<h1 className="text-5xl text-white text-center mb-10">
{data.title}
</h1>

View file

@ -44,7 +44,7 @@ export default function Projects() {
return (
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
<div className="flex flex-col gap-5 pt-10">
<div className="flex flex-col pt-10">
<h1 className="text-5xl text-white text-center mb-10">
{data.title}
</h1>

View file

@ -31,7 +31,7 @@ export default function Projects() {
return (
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
<div className="flex flex-col gap-5 pt-10">
<div className="flex flex-col pt-10">
<h1 className="text-5xl text-white text-center mb-10">
{data.title}
</h1>

View file

@ -31,7 +31,7 @@ export default function Projects() {
return (
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
<div className="flex flex-col gap-5 pt-10">
<div className="flex flex-col pt-10">
<h1 className="text-5xl text-white text-center mb-10">
{data.title}
</h1>