From c757f8df8b2ea3fc5fca03e671b507a4f1ff5864 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Fri, 28 Oct 2022 11:05:13 +0200 Subject: [PATCH] Handle empty string in `Markdown` component We expect the `Markdown` component to receive a `content: string`, but we also check if `content` is truthy before rendering anything, and this can get messy when `content` is an empty string. Fixed by removing the truthy check for `content`. Signed-off-by: Sebastian Martinez --- src/Markdown.svelte | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Markdown.svelte b/src/Markdown.svelte index 61f153537..f3603dfb6 100644 --- a/src/Markdown.svelte +++ b/src/Markdown.svelte @@ -248,21 +248,19 @@ } -{#if content} - {#if frontMatter.length > 0} -
- - {#each frontMatter as [key, val]} - - - - - {/each} -
{key}{val}
-
- {/if} - -
- {@html render(doc.content)} +{#if frontMatter.length > 0} +
+ + {#each frontMatter as [key, val]} + + + + + {/each} +
{key}{val}
{/if} + +
+ {@html render(doc.content)} +