From 45026eee4c93bbbe6141dd23a664abe6e9ff3ca2 Mon Sep 17 00:00:00 2001 From: nolawz Date: Tue, 3 Mar 2026 04:04:23 +0530 Subject: Added events section and components required for that --- src/pages/events/[...id].astro | 168 +++++++++++++++++++++++++++++++++++++++ src/pages/events/[...page].astro | 60 ++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 src/pages/events/[...id].astro create mode 100644 src/pages/events/[...page].astro (limited to 'src/pages/events') diff --git a/src/pages/events/[...id].astro b/src/pages/events/[...id].astro new file mode 100644 index 0000000..44d8ec4 --- /dev/null +++ b/src/pages/events/[...id].astro @@ -0,0 +1,168 @@ +--- +import Breadcrumbs from '@/components/Breadcrumbs.astro' +import EventNavigation from '@/components/EventNavigation.astro' +import TOCHeader from '@/components/TOCHeader.astro' +import TOCSidebar from '@/components/TOCSidebar.astro' +import { badgeVariants } from '@/components/ui/badge' +import { Button } from '@/components/ui/button' +import Layout from '@/layouts/Layout.astro' +import { + getAdjacentEvents, + getAllEvents, + getTOCSections, +} from '@/lib/data-utils' +import { formatDate, iconMappings } from '@/lib/utils' +import { Icon } from 'astro-icon/components' +import { Image } from 'astro:assets' +import { render } from 'astro:content' + +export async function getStaticPaths() { + const events = await getAllEvents() + return events.map((event) => ({ + params: { id: event.id }, + props: event, + })) +} + +const event = Astro.props +const currentPostId = Astro.params.id +const navigation = await getAdjacentEvents(currentPostId) +const { Content, headings } = await render(event) + +const tocSections = await getTOCSections(currentPostId) +--- + + + { + headings?.length > 0 && + !(headings.length === 1 && headings[0].text === event.data.title) && ( + + ) + } + +
+
+ +
+ + { + event.data.image && ( + {event.data.title} + ) + } + +
+
+

+ {event.data.title} +

+ +
+
+ {formatDate(event.data.date)} +
+
+
+ { + event.data.type && ( + + + {event.data.type} + + ) + } +
+
+
+ + { + tocSections.length > 0 && ( + + ) + } + +
+ +
+ + +
+ + + + +
+ + diff --git a/src/pages/events/[...page].astro b/src/pages/events/[...page].astro new file mode 100644 index 0000000..2625ab0 --- /dev/null +++ b/src/pages/events/[...page].astro @@ -0,0 +1,60 @@ +--- +import Breadcrumbs from '@/components/Breadcrumbs.astro' +import EventCard from '@/components/EventCard.astro' +import PageHead from '@/components/PageHead.astro' +import PaginationComponent from '@/components/ui/pagination' +import { SITE } from '@/consts' +import Layout from '@/layouts/Layout.astro' +import { getAllEvents, groupEventsByYear } from '@/lib/data-utils' +import type { PaginateFunction } from 'astro' + +export async function getStaticPaths({ + paginate, +}: { + paginate: PaginateFunction +}) { + const allEvents = await getAllEvents() + return paginate(allEvents, { pageSize: SITE.eventsPerPage }) +} + +const { page } = Astro.props + +const eventsByYear = groupEventsByYear(page.data) +const years = Object.keys(eventsByYear).sort( + (a, b) => parseInt(b) - parseInt(a), +) +--- + + + + + +
+ { + years.map((year) => ( +
+
{year}
+
    + {eventsByYear[year].map((event) => ( +
  • + +
  • + ))} +
+
+ )) + } +
+ + +
-- cgit v1.2.3