From c6a4c239a06ff3cf2a27efc75bdfc6dd34245b36 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 4 Nov 2022 09:58:54 +0100 Subject: [PATCH] #449 - Show `filename` if the `title` is not set --- CHANGELOG.md | 1 + src/services/PagesParser.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a362d496..7d93b76b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - [#428](https://github.com/estruyf/vscode-front-matter/issues/428): Improved UX for inserting images to your content - [#430](https://github.com/estruyf/vscode-front-matter/issues/430): Support for HEXO its `post_asset_folder` setting (image location) - [#434](https://github.com/estruyf/vscode-front-matter/issues/434): Webview errors are logged in the extension output +- [#449](https://github.com/estruyf/vscode-front-matter/issues/449): Show `filename` if the `title` is not set ### ⚡️ Optimizations diff --git a/src/services/PagesParser.ts b/src/services/PagesParser.ts index 2f7200b9..0120e4b1 100644 --- a/src/services/PagesParser.ts +++ b/src/services/PagesParser.ts @@ -126,8 +126,9 @@ export class PagesParser { */ public static async processPageContent(filePath: string, fileMtime: number, fileName: string, folderTitle: string): Promise { const article = await ArticleHelper.getFrontMatterByPath(filePath); + const articleTitle = article?.data.title || fileName; - if (article?.data.title) { + if (article?.data) { const wsFolder = Folders.getWorkspaceFolder(); const descriptionField = Settings.get(SETTING_SEO_DESCRIPTION_FIELD) as string || DefaultFields.Description; @@ -139,7 +140,7 @@ export class PagesParser { const staticFolder = Folders.getStaticFolderRelativePath(); - let escapedTitle = article?.data.title; + let escapedTitle = articleTitle; if (escapedTitle && typeof escapedTitle !== "string") { escapedTitle = ""; }