From a4618b17d0fb893aa2286ebfb5accdf84704c8a6 Mon Sep 17 00:00:00 2001 From: Thomas Parisot <138627+thom4parisot@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:04:39 +0200 Subject: [PATCH] fix: accepte un rendu de Yaml vide (#1029) Co-authored-by: Thomas Parisot --- front/src/components/Write/PreviewPaged.jsx | 2 +- front/src/components/Write/yamleditor/YamlEditor.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/components/Write/PreviewPaged.jsx b/front/src/components/Write/PreviewPaged.jsx index e5506caef..e0aa6465f 100644 --- a/front/src/components/Write/PreviewPaged.jsx +++ b/front/src/components/Write/PreviewPaged.jsx @@ -19,7 +19,7 @@ export default function Preview ({ preview, yaml }) { useEffect(() => { if (html && isLoading) { - const [metadata] = YAML.loadAll(yaml) + const [metadata = {}] = YAML.loadAll(yaml) const render = compileTemplate(template) const base64Stylesheet = `data:text/css;base64,${btoa(stylesheet)}` diff --git a/front/src/components/Write/yamleditor/YamlEditor.jsx b/front/src/components/Write/yamleditor/YamlEditor.jsx index 2cce60ed7..c3fa7e899 100644 --- a/front/src/components/Write/yamleditor/YamlEditor.jsx +++ b/front/src/components/Write/yamleditor/YamlEditor.jsx @@ -3,7 +3,7 @@ import Form from '../../Form' import YAML from 'js-yaml' export default function YamlEditor ({ yaml, basicMode, onChange }) { - const [parsed] = YAML.loadAll(yaml) + const [parsed = {}] = YAML.loadAll(yaml) // we convert YYYY/MM/DD dates into ISO YYYY-MM-DD if (parsed.date) {