diff --git a/src/lib/js/stripHtmlTags.ts b/src/lib/js/stripHtmlTags.ts new file mode 100644 index 0000000..b6642b2 --- /dev/null +++ b/src/lib/js/stripHtmlTags.ts @@ -0,0 +1,7 @@ +// Function to strip HTML tags from a string +function stripHtmlTags(input) { + const parser = new DOMParser(); + const doc = parser.parseFromString(input, 'text/html'); + const textContent = doc.body.textContent || ""; + return textContent; +} diff --git a/src/routes/(rezepte)/rezepte/[name]/+page.svelte b/src/routes/(rezepte)/rezepte/[name]/+page.svelte index 1cd5431..3306381 100644 --- a/src/routes/(rezepte)/rezepte/[name]/+page.svelte +++ b/src/routes/(rezepte)/rezepte/[name]/+page.svelte @@ -11,6 +11,7 @@ import { afterNavigate } from '$app/navigation'; import {season} from '$lib/js/season_store'; import RecipeNote from '$lib/components/RecipeNote.svelte'; + import {stripHtmlTags} from '$lib/js/stripHtmlTags'; export let data: PageData; @@ -206,12 +207,12 @@ h4{ } - Bocken - {@html data.name} - + Bocken - {stripHtmlTags(data.name)} + - +