Render upcoming event markdown as HTML
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
import { upcomingEvent as UpcomingEvent } from './subcomponents/UpcomingEvent';
|
import { upcomingEvent as UpcomingEvent } from './subcomponents/UpcomingEvent';
|
||||||
|
import { markdownToHtml } from '@/lib/markdown';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
upcomingEvents: UpcomingEventsComponent;
|
upcomingEvents: UpcomingEventsComponent;
|
||||||
@@ -36,7 +37,15 @@ const upcomingEvents = Astro.props.upcomingEvents;
|
|||||||
) }
|
) }
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3.5">
|
<div class="mt-3.5">
|
||||||
<UpcomingEvent event={event} client:load />
|
<UpcomingEvent
|
||||||
|
client:load
|
||||||
|
event={{
|
||||||
|
title: event.title,
|
||||||
|
description: markdownToHtml(event.description),
|
||||||
|
startDate: event.startDate,
|
||||||
|
endDate: event.endDate
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CalendarIcon } from "@/icons/jsx/calendarIcon";
|
import { CalendarIcon } from "@/icons/jsx/calendarIcon";
|
||||||
import { useState } from "preact/hooks"
|
import { useState } from "preact/hooks"
|
||||||
|
|
||||||
export function upcomingEvent(props: { event: UpcomingEvent }) {
|
export function upcomingEvent(props: { event: UpcomingEventProps }) {
|
||||||
const [ isOpen, setIsOpen ] = useState<boolean>(false);
|
const [ isOpen, setIsOpen ] = useState<boolean>(false);
|
||||||
const [ isVisible, setIsVisible ] = useState<boolean>(false);
|
const [ isVisible, setIsVisible ] = useState<boolean>(false);
|
||||||
|
|
||||||
@@ -40,8 +40,7 @@ export function upcomingEvent(props: { event: UpcomingEvent }) {
|
|||||||
) }
|
) }
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-3">
|
<div className="mt-3" dangerouslySetInnerHTML={{ __html: props.event.description }}>
|
||||||
{ props.event.description }
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
10
astro/src/types/components/events.d.ts
vendored
10
astro/src/types/components/events.d.ts
vendored
@@ -14,6 +14,14 @@ type UpcomingEvent = {
|
|||||||
location: string;
|
location: string;
|
||||||
mapLocation: [number, number];
|
mapLocation: [number, number];
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
endDate: Date;
|
endDate: Date | null;
|
||||||
thumbnail: PhotoProps;
|
thumbnail: PhotoProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UpcomingEventProps = {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
startDate: Date;
|
||||||
|
endDate: Date | null;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user