From 5c9d7eda1763fa11e9ed9e812fd6e1cd0ee7d8a1 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Sun, 2 Oct 2022 20:01:59 +0200 Subject: [PATCH] #433 - fix title and description rendering if not string --- CHANGELOG.md | 2 ++ .../components/Contents/Item.tsx | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba79bc65..2951ed9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ ### 🐞 Fixes +- [#433](https://github.com/estruyf/vscode-front-matter/issues/433): Fix issue with rendering an incorrect title value on the content dashboard + ## [8.1.1] - 2022-09-23 ### 🐞 Fixes diff --git a/src/dashboardWebView/components/Contents/Item.tsx b/src/dashboardWebView/components/Contents/Item.tsx index bfd4becc..3f140774 100644 --- a/src/dashboardWebView/components/Contents/Item.tsx +++ b/src/dashboardWebView/components/Contents/Item.tsx @@ -19,6 +19,22 @@ export const Item: React.FunctionComponent = ({ fmFilePath, date, ti const view = useRecoilValue(ViewSelector); const settings = useRecoilValue(SettingsSelector); const draftField = useMemo(() => settings?.draftField, [settings]); + + const escapedTitle = useMemo(() => { + if (title && typeof title !== 'string') { + return ''; + } + + return title; + }, [title]); + + const escapedDescription = useMemo(() => { + if (description && typeof description !== 'string') { + return ''; + } + + return description; + }, [description]); const openFile = () => { Messenger.send(DashboardMessage.openFile, fmFilePath); @@ -57,7 +73,7 @@ export const Item: React.FunctionComponent = ({ fmFilePath, date, ti + - + { tags && tags.length > 0 && ( @@ -110,13 +126,13 @@ export const Item: React.FunctionComponent = ({ fmFilePath, date, ti