Fixed description by manually implementing asSafeHTML (#5321)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/5208/head^2
Alex van Andel 2022-11-01 15:42:48 +00:00 committed by GitHub
parent a8710ce625
commit 98f6fd836e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import MarkdownIt from "markdown-it";
import { GetStaticPaths, GetStaticPropsContext } from "next"; import { GetStaticPaths, GetStaticPropsContext } from "next";
import { JSONObject } from "superjson/dist/types"; import { JSONObject } from "superjson/dist/types";
import { z } from "zod"; 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 }; if (!user || !user.eventTypes) return { notFound: true };
const [eventType]: (typeof user.eventTypes[number] & { const [eventType]: (typeof user.eventTypes[number] & {
@ -139,6 +148,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}), metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}),
recurringEvent: parseRecurringEvent(eventType.recurringEvent), recurringEvent: parseRecurringEvent(eventType.recurringEvent),
locations: privacyFilteredLocations(locations), locations: privacyFilteredLocations(locations),
descriptionAsSafeHTML: eventType.description ? md.render(eventType.description) : null,
}); });
return { return {