From 0d664184053c20407878953c6f3c622183d64eeb Mon Sep 17 00:00:00 2001 From: itziarZG Date: Sat, 17 Jan 2026 18:30:11 +0100 Subject: [PATCH 1/3] feat: add dynamic menu with astro content --- src/content/config.ts | 24 ++++ src/content/menu/main.json | 42 ++++++ src/layouts/Layout.astro | 6 +- src/layouts/components/Nav.astro | 220 +++++++++++++++++++++++++++++++ 4 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 src/content/config.ts create mode 100644 src/content/menu/main.json create mode 100644 src/layouts/components/Nav.astro diff --git a/src/content/config.ts b/src/content/config.ts new file mode 100644 index 0000000..3d238b6 --- /dev/null +++ b/src/content/config.ts @@ -0,0 +1,24 @@ +import { defineCollection, z } from 'astro:content'; + +const menuCollection = defineCollection({ + type: 'data', + schema: z.object({ + items: z.array( + z.object({ + label: z.string(), + href: z.string().optional(), + // optional + children: z.array( + z.object({ + label: z.string(), + href: z.string(), + }) + ).optional(), + }) + ) + }) +}); + +export const collections = { + 'menu': menuCollection, +}; \ No newline at end of file diff --git a/src/content/menu/main.json b/src/content/menu/main.json new file mode 100644 index 0000000..4d54c8c --- /dev/null +++ b/src/content/menu/main.json @@ -0,0 +1,42 @@ +{ + "items": [ + { + "label": "Inicio", + "href": "/" + }, + { + "label": "La Conferencia", + "children": [ + { + "label": "Speakers", + "href": "/speakers" + }, + { + "label": "Agenda", + "href": "/agenda" + }, + { + "label": "Sede", + "href": "/location" + } + ] + }, + { + "label": "Patrocinios", + "href": "/sponsorship" + }, + { + "label": "Ediciones Anteriores", + "children": [ + { + "label": "2025 (Sevilla)", + "href": "https://2025.es.pycon.org" + }, + { + "label": "2024 (Vigo)", + "href": "https://2024.es.pycon.org" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 0c917dc..1f6bd0e 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -2,6 +2,7 @@ import '../style/global.css' import '@fontsource-variable/jetbrains-mono' import { ClientRouter } from 'astro:transitions' +import Nav from './components/Nav.astro' interface Props { title: string @@ -28,7 +29,10 @@ const { title, description = 'PyconES 2026' } = Astro.props - +