chore: fixed bugs in macchinisti page and some refactoring

dev
Antonio De Lucreziis 3 months ago
parent 2dbdf99827
commit e49e2ff0c5

@ -3,8 +3,13 @@ import preact from '@astrojs/preact'
import mdx from '@astrojs/mdx' import mdx from '@astrojs/mdx'
import yaml from '@rollup/plugin-yaml'
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
vite: {
plugins: [yaml()],
},
server: { server: {
port: 3000, port: 3000,
}, },
@ -14,5 +19,5 @@ export default defineConfig({
}, },
}, },
integrations: [preact(), mdx()], integrations: [preact(), mdx()],
output: 'static' output: 'static',
}) })

Binary file not shown.

@ -31,6 +31,7 @@
}, },
"devDependencies": { "devDependencies": {
"@astrojs/mdx": "^3.1.7", "@astrojs/mdx": "^3.1.7",
"@rollup/plugin-yaml": "^4.1.2",
"@types/katex": "^0.16.7", "@types/katex": "^0.16.7",
"jsdom": "^24.1.1", "jsdom": "^24.1.1",
"linkedom": "^0.18.4", "linkedom": "^0.18.4",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

@ -14,7 +14,8 @@ const ICONS_MAP = {
type Props = { type Props = {
image: ImageMetadata image: ImageMetadata
fullName: string fullName: string
date: string entranceDate: number
exitDate?: number
description: string description: string
social?: { social?: {
github?: string github?: string
@ -24,13 +25,13 @@ type Props = {
} }
} }
const { image, fullName, date, description, social } = Astro.props const { image, fullName, entranceDate, exitDate, description, social } = Astro.props
--- ---
<div class="bubble"> <div class="bubble">
<img src={image.src} alt={fullName.toLowerCase()} /> <img src={image.src} alt={fullName.toLowerCase()} />
<div class="title">{fullName}</div> <div class="title">{fullName}</div>
<div class="date">{date}</div> <div class="date">{entranceDate}&mdash;{exitDate ?? 'Presente'}</div>
<div class="description">{description}</div> <div class="description">{description}</div>
{ {
social && ( social && (

@ -1,17 +1,36 @@
---
const links = [
{ href: '/utenti', text: 'Utenti' },
// { href: '/macchinisti', text: 'Macchinisti' },
// { href: '/appunti', text: 'Appunti' },
{ href: '/notizie', text: 'Notizie' },
{ href: '/guide', text: 'Guide' },
{ href: '/storia', text: 'Storia' },
// { href: '/login', text: 'Login' },
]
---
<header> <header>
<!-- main logo on the left -->
<a href="/" class="logo"> <a href="/" class="logo">
<img src="/images/phc-logo-2024-11@x8.png" alt="phc logo" /> <img src="/images/phc-logo-2024-11@x8.png" alt="phc logo" />
</a> </a>
<!-- hidden checkbox for mobile js-less sidebar interaction -->
<input type="checkbox" id="header-menu-toggle" /> <input type="checkbox" id="header-menu-toggle" />
<!-- desktop navbar links -->
<div class="links desktop-only"> <div class="links desktop-only">
<a role="button" href="/utenti">Utenti</a> {
<a role="button" href="/macchinisti">Macchinisti</a> links.map(link => (
<!-- <a role="button" href="/appunti">Appunti</a> --> <a role="button" href={link.href}>
<a role="button" href="/notizie">Notizie</a> {link.text}
<a role="button" href="/guide">Guide</a> </a>
<a role="button" href="/storia">Storia</a> ))
<!-- <a class="primary" role="button" href="/login">Login</a> --> }
</div> </div>
<!-- sidebar menu for mobile -->
<div class="mobile-only"> <div class="mobile-only">
<label id="header-menu-toggle-menu" role="button" class="flat icon" for="header-menu-toggle"> <label id="header-menu-toggle-menu" role="button" class="flat icon" for="header-menu-toggle">
<span class="material-symbols-outlined">menu</span> <span class="material-symbols-outlined">menu</span>
@ -20,15 +39,17 @@
<span class="material-symbols-outlined">close</span> <span class="material-symbols-outlined">close</span>
</label> </label>
</div> </div>
<!-- sidebar menu only visible on mobile when #header-menu-toggle is checked -->
<div class="side-menu"> <div class="side-menu">
<div class="links"> <div class="links">
<a role="button" href="/utenti">Utenti</a> {
<a role="button" href="/macchinisti">Macchinisti</a> links.map(link => (
<!-- <a role="button" href="/appunti">Appunti</a> --> <a role="button" href={link.href}>
<a role="button" href="/notizie">Notizie</a> {link.text}
<a role="button" href="/guide">Guide</a> </a>
<a role="button" href="/storia">Storia</a> ))
<!-- <a class="primary" role="button" href="/login">Login</a> --> }
</div> </div>
</div> </div>
</header> </header>

@ -1,47 +0,0 @@
[
{
"fullName": "Antonio De Lucreziis",
"dateIn": "2019",
"dateOut": "",
"description": "Description here",
"github": "https://github.com/adelucreziis",
"website": "",
"linkedin": ""
},
{
"fullName": "Luca Lombardo",
"dateIn": "2024",
"dateOut": "",
"description": "Algoritmi e Strutture Dati Bla Bla",
"github": "https://github.com/lukefleed",
"website": "https://lukefleex.xyz",
"linkedin": "https://www.linkedin.com/in/l-lombardo/"
},
{
"fullName": "Francesco Minnocci",
"dateIn": "2022",
"dateOut": "",
"description": "Ho una laurea(?)",
"github": "https://github.com/BachoSeven",
"website": "https://bachoseven.com",
"linkedin": ""
},
{
"fullName": "Francesco Baldino",
"dateIn": "2022",
"dateOut": "",
"description": "Bla Bla",
"github": "",
"website": "",
"linkedin": ""
},
{
"fullName": "Illya Serdyuk",
"dateIn": "2019",
"dateOut": "",
"description": "Bla Bla",
"github": "",
"website": "",
"linkedin": ""
}
]

@ -0,0 +1,35 @@
- fullName: Antonio De Lucreziis
entranceDate: 2019
description: |
Appassionato di geometria computazionale, parser, teoria dei linguaggi di programmazione.
social:
github: https://github.com/aziis98
website: https://poisson.phc.dm.unipi.it/~delucreziis/
- fullName: Luca Lombardo
entranceDate: 2024
description: Algoritmi e Strutture Dati bla bla
social:
github: https://github.com/lukefleed
website: https://lukefleex.xyz
linkedin: https://www.linkedin.com/in/l-lombardo/
- fullName: Francesco Minnocci
entranceDate: 2022
description: Ho una laurea (?), bla bla tastiere meccaniche
social:
github: https://github.com/BachoSeven
website: https://bachoseven.com
- fullName: Francesco Baldino
entranceDate: 2022
description: Bla bla Star Wars
- fullName: Illya Serdyuk
entranceDate: 2020
description: Bla bla Void Linux
- fullName: Francesco Manicastri
entranceDate: 2022
exitDate: 2024
description: Bla bla Keenan Crane

@ -1,11 +0,0 @@
[
{
"fullName": "Francesco Manicastri",
"dateIn": "2022",
"dateOut": "2024",
"description": "Geometria bla bla",
"github": "",
"website": "",
"linkedin": ""
}
]

17
src/files.d.ts vendored

@ -0,0 +1,17 @@
declare module '*.yaml' {
const value: any // Add type definitions here if desired
export default value
}
declare module '@/data/macchinisti.yaml' {
type Macchinista = {
fullName: string
entranceDate: number
exitDate?: number
description: string
social: Record<string, string>
}
const value: Macchinista[]
export default value
}

@ -4,28 +4,31 @@ import Header from '../components/Header.astro'
import Footer from '../components/Footer.astro' import Footer from '../components/Footer.astro'
import Bubble from '../components/Bubble.astro' import Bubble from '../components/Bubble.astro'
import currentMacchinisti from '../data/current-macchinisti.json' import macchinisti from '@/data/macchinisti.yaml'
import pastMacchinisti from '../data/past-macchinisti.json' macchinisti.sort((a, b) => b.entranceDate - a.entranceDate)
// Import all images from assets folder // Import all images from assets folder
const images = import.meta.glob('@/assets/macchinisti/*.{jpg,jpeg,png,gif}', { const images: Record<string, ImageMetadata> = Object.fromEntries(
eager: true await Promise.all(
}) Object.entries(import.meta.glob('@/assets/macchinisti/*')).map(async ([path, module]) => [
path.split('/').pop()!.split('.')[0],
// @ts-ignore
(await module()).default,
])
)
)
// Sort by dateIn console.log(macchinisti)
const sortedCurrent = currentMacchinisti.sort((a, b) => parseInt(a.dateIn) - parseInt(b.dateIn)) console.log(images)
const sortedPast = pastMacchinisti.sort((a, b) => parseInt(a.dateIn) - parseInt(b.dateIn))
// Define a fallback image metadata const currentMacchinisti = macchinisti.filter(macchinista => !macchinista.exitDate)
const fallbackImage = { default: 'assets/macchinisti/fallback.jpg' } const pastMacchinisti = macchinisti.filter(macchinista => macchinista.exitDate)
// Function to get image for a macchinista const getMacchinistaPicture = (fullName: string): ImageMetadata => {
const getImage = (fullName: string) => { const macchinistaId = fullName.toLowerCase().replace(/\s+/g, '-')
const imageName = fullName.toLowerCase().replaceAll(' ', '-') console.log(macchinistaId)
const imageModule = Object.entries(images).find(([path]) =>
path.includes(imageName) return images[macchinistaId] ?? images['fallback']
)?.[1]
return imageModule || fallbackImage
} }
--- ---
@ -40,42 +43,39 @@ const getImage = (fullName: string) => {
</div> </div>
<div class="bubble-array"> <div class="bubble-array">
{sortedCurrent.map(async (macchinista) => ( {
<Bubble currentMacchinisti.map(macchinista => (
image={(getImage(macchinista.fullName) as { default: string }).default as unknown as ImageMetadata} <Bubble
fullName={macchinista.fullName} image={getMacchinistaPicture(macchinista.fullName)}
date={`${macchinista.dateIn}—Presente`} fullName={macchinista.fullName}
description={macchinista.description} entranceDate={macchinista.entranceDate}
social={{ description={macchinista.description}
...(macchinista.github && { github: macchinista.github }), social={macchinista.social}
...(macchinista.website && { website: macchinista.website }), />
...(macchinista.linkedin && { linkedin: macchinista.linkedin }) ))
}} }
/>
))}
</div> </div>
<div class="card large" style={{ '--card-base': '#6BD6E1' }}> <div class="card large" style={{ '--card-base': '#6BD6E1' }}>
<div class="title">Ex Macchinisti</div> <div class="title"><s>Deus</s> Ex Macchinisti</div>
<div class="text"> <div class="text">
<p>Gli vogliamo molto bene, hanno fatto grandi cose!</p> <p>Gli vogliamo molto bene, hanno fatto grandi cose!</p>
</div> </div>
</div> </div>
<div class="bubble-array"> <div class="bubble-array">
{sortedPast.map(async (macchinista) => ( {
<Bubble pastMacchinisti.map(macchinista => (
image={(getImage(macchinista.fullName) as { default: string }).default as unknown as ImageMetadata} <Bubble
fullName={macchinista.fullName} image={getMacchinistaPicture(macchinista.fullName)}
date={`${macchinista.dateIn}—${macchinista.dateOut}`} fullName={macchinista.fullName}
description={macchinista.description} entranceDate={macchinista.entranceDate}
social={{ exitDate={macchinista.exitDate}
...(macchinista.github && { github: macchinista.github }), description={macchinista.description}
...(macchinista.website && { website: macchinista.website }), social={macchinista.social}
...(macchinista.linkedin && { linkedin: macchinista.linkedin }) />
}} ))
/> }
))}
</div> </div>
</main> </main>
<Footer /> <Footer />

@ -818,4 +818,48 @@
} }
} }
} }
.bubble-array {
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: center;
gap: 3rem 6rem;
> .bubble {
display: grid;
grid-template-rows: auto auto auto auto;
grid-auto-rows: auto;
gap: 0.5rem;
text-align: center;
justify-items: center;
align-content: start;
width: 25ch;
.date {
display: grid;
place-content: center;
font-size: 16px;
font-weight: 600;
padding: 0.25rem 0.5rem;
background: #0002;
border-radius: 0.25rem;
}
.social {
display: grid;
grid-auto-flow: column;
gap: 0.5rem;
justify-content: center;
}
> img {
border-radius: 100%;
border: 4px solid #333;
object-fit: cover;
width: 100%;
aspect-ratio: 1 / 1;
}
}
}
} }

@ -646,52 +646,9 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 6rem 4rem; padding: 6rem;
gap: 4rem; gap: 4rem;
} }
.bubble-array {
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: center;
gap: 4rem;
> .bubble {
display: grid;
grid-template-rows: auto auto auto auto;
grid-auto-rows: auto;
gap: 0.5rem;
text-align: center;
justify-items: center;
width: 25ch;
.date {
display: grid;
place-content: center;
font-size: 16px;
font-weight: 600;
padding: 0rem 0.5rem;
background: #0002;
border-radius: 0.25rem;
}
.social {
display: grid;
grid-auto-flow: column;
gap: 0.5rem;
justify-content: center;
}
> img {
border-radius: 100%;
border: 4px solid #333;
object-fit: cover;
width: 100%;
aspect-ratio: 1 / 1;
}
}
}
} }
// //

Loading…
Cancel
Save