From 98f6fd836e59ec0e176639e2dc0f9496dc503b68 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 1 Nov 2022 15:42:48 +0000 Subject: [PATCH] Fixed description by manually implementing asSafeHTML (#5321) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/web/pages/[user]/[type].tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/web/pages/[user]/[type].tsx b/apps/web/pages/[user]/[type].tsx index 398e8e8c18..01102656e8 100644 --- a/apps/web/pages/[user]/[type].tsx +++ b/apps/web/pages/[user]/[type].tsx @@ -1,3 +1,4 @@ +import MarkdownIt from "markdown-it"; import { GetStaticPaths, GetStaticPropsContext } from "next"; import { JSONObject } from "superjson/dist/types"; import { z } from "zod"; @@ -112,6 +113,14 @@ async function getUserPageProps(context: GetStaticPropsContext) { }, }); + const md = new MarkdownIt("zero").enable([ + // + "emphasis", + "list", + "newline", + "strikethrough", + ]); + if (!user || !user.eventTypes) return { notFound: true }; const [eventType]: (typeof user.eventTypes[number] & { @@ -139,6 +148,7 @@ async function getUserPageProps(context: GetStaticPropsContext) { metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}), recurringEvent: parseRecurringEvent(eventType.recurringEvent), locations: privacyFilteredLocations(locations), + descriptionAsSafeHTML: eventType.description ? md.render(eventType.description) : null, }); return {