diff --git a/astro.config.mjs b/astro.config.mjs index e9a6363..1831c87 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -18,6 +18,11 @@ export default defineConfig({ theme: 'github-light', }, }, - integrations: [preact(), mdx()], + integrations: [ + preact({ + compat: true, + }), + mdx(), + ], output: 'static', }) diff --git a/bun.lockb b/bun.lockb index fe08456..d1ef97b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4d7fdde..9eefc62 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@fontsource/source-sans-pro": "^5.0.8", "@fontsource/space-mono": "^5.0.20", "@phosphor-icons/core": "^2.1.1", + "@phosphor-icons/react": "^2.1.7", "@preact/signals": "^1.3.0", "@types/jsdom": "^21.1.7", "astro": "5.1.0", diff --git a/src/client/DomandeEsamiCourse.tsx b/src/client/DomandeEsamiCourse.tsx new file mode 100644 index 0000000..259177b --- /dev/null +++ b/src/client/DomandeEsamiCourse.tsx @@ -0,0 +1,116 @@ +import { useEffect, useState } from 'preact/hooks' +import { Funnel } from '@phosphor-icons/react' +import { marked } from 'marked' + +import type { Database } from '@/data/domande-esami.yaml' + +const useRemoteValue = (url: string): T | null => { + const [value, setValue] = useState(null) + + useEffect(() => { + fetch(url) + .then(response => response.json()) + .then(value => setValue(value)) + }, [url]) + + return value +} + +type Props = { + course: string +} + +export const DomandeEsamiCourse = ({ course }: Props) => { + const database = useRemoteValue(`/domande-esami/api/${course}.json`) + if (!database) { + return <>Loading... + } + + // @ts-ignore + requestIdleCallback(() => window.renderMath()) + + console.log(database) + + const courseTags = [ + ...new Set( + database.questions + .filter(question => question.course === course) + .flatMap(question => question.tags) + ), + ] + + const [selectedTags, setSelectedTags] = useState([]) + + const filteredQuestions = database.questions + .filter(question => question.course === course) + .filter( + question => selectedTags.length === 0 || selectedTags.every(tag => question.tags.includes(tag)) + ) + + return ( + <> +
+

+ Domande Esami +

+

{database.names[course]}

+
+ +
+
+ + Filtra Tag +
+
+ {selectedTags.length === 0 + ? courseTags.map(tag => ( +
setSelectedTags([tag])}> + {tag} +
+ )) + : courseTags.map(tag => ( +
+ setSelectedTags( + selectedTags.includes(tag) + ? selectedTags.filter(t => t !== tag) + : [...selectedTags, tag] + ) + } + > + {tag} +
+ ))} +
+
+
+ {filteredQuestions.length === 0 ? ( +
+ No questions found +
+ ) : ( + filteredQuestions.map(question => ( +
+
+ +
+ )) + )} +
+ + ) +} diff --git a/src/data/domande-esami.yaml b/src/data/domande-esami.yaml index 3549afe..2ed339d 100644 --- a/src/data/domande-esami.yaml +++ b/src/data/domande-esami.yaml @@ -21,7 +21,7 @@ names: groups: - id: triennale-anno-1 - name: Triennale - Anno I + name: I Anno Triennale items: - aritmetica - geometria-1 @@ -29,14 +29,14 @@ groups: - algebra-1 - id: triennale-anno-2 - name: Triennale - Anno II + name: II Anno Triennale items: - geometria-2 - analisi-2 - algebra-1 - id: triennale-anno-3 - name: Triennale - Anno III + name: III Anno Triennale items: - ricerca-operativa - fisica-3 @@ -60,101 +60,142 @@ groups: questions: - course: geometria-1 - year: 2024 content: | Dimostrare il teorema spettrale reale + tags: + - 2024 - course: gtd - year: 2024 content: | Calcolare la curvatura gaussiana di una sfera di raggio $r$ + tags: + - 2024 - course: geometria-1 - year: 2023 content: | Dimostrare che _l'area_ di un cerchio è $A = \pi r^2$ + tags: + - 2023 - course: algebra-1 - year: 2024 content: | Dimostrare il teorema di Sylow + tags: + - 2024 - course: algebra-1 - year: 2023 content: | Dimostrare che ogni sottogruppo di un gruppo ciclico è ciclico + tags: + - 2023 - course: analisi-1 - year: 2024 content: | Dimostrare il teorema di Weierstrass + tags: + - 2024 - course: analisi-1 - year: 2023 content: | Dimostrare che se $f$ è continua su $[a,b]$, allora $f$ è limitata + tags: + - 2023 - course: analisi-2 - year: 2024 content: | Dimostrare il teorema di Stokes + tags: + - 2024 - course: analisi-2 - year: 2023 content: | Dimostrare il teorema di Green + tags: + - 2023 - course: analisi-3 - year: 2024 content: | Dimostrare il teorema di Cauchy + tags: + - 2024 - course: analisi-3 - year: 2023 content: | Dimostrare il teorema di Liouville + tags: + - 2023 - course: algebra-2 - year: 2024 content: | Dimostrare il teorema di struttura per i gruppi abeliani finiti + tags: + - 2024 - course: algebra-2 - year: 2023 content: | Dimostrare il teorema di struttura per i gruppi finiti + tags: + - 2023 - course: ricerca-operativa - year: 2024 content: | Dimostrare il teorema di dualità per i problemi di programmazione lineare + tags: + - 2024 - course: geometria-topologia-differenziale - year: 2024 content: | Dimostrare il teorema di Poincaré-Hopf + tags: + - 2024 - course: analisi-armonica - year: 2024 content: | Dimostrare il teorema di Hahn-Banach + tags: + - 2024 - course: analisi-complessa - year: 2024 content: | Dimostrare il teorema di Morera + tags: + - 2024 - course: analisi-complessa - year: 2023 content: | Dimostrare il teorema degli zeri di Weierstrass + tags: + - 2023 - course: analisi-complessa - year: 2022 content: | Dimostrare il teorema della mappa aperta + tags: + - 2022 - course: analisi-complessa - year: 2021 content: | Dimostrare il teorema della mappa aperta + tags: + - 2021 + + - course: geometria-2 + content: | + Dimostrare il teorema di Van Kampen + tags: + - 2024 + - Frigerio + + - course: geometria-2 + content: | + Definizione di gruppo fondamentale + tags: + - 2023 + - Frigerio + + - course: geometria-2 + content: | + Dimostrare il teorema Cauchy + tags: + - 2022 + - Abate diff --git a/src/files.d.ts b/src/files.d.ts index 975bb65..fb0b88c 100644 --- a/src/files.d.ts +++ b/src/files.d.ts @@ -17,21 +17,24 @@ declare module '@/data/macchinisti.yaml' { } declare module '@/data/domande-esami.yaml' { - type Question = { + export type Question = { course: string - year: number content: string + tags: string[] } - type Group = { + export type Group = { id: string name: string items: Array } - const names: Record - const groups: Group[] - const questions: Question[] + export type Database = { + names: Record + groups: Group[] + questions: Question[] + } - export { names, groups, questions } + const value: Database + export default value } diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 57c35b7..0929185 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -44,7 +44,7 @@ const { title, description, thumbnail, pageTags } = Astro.props