From 2e35da3d91ec2ce698c0938ee9f782af80ee985e Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 28 Feb 2024 15:54:11 +0100 Subject: [PATCH] #746 - Fix in path placeholders on content creation --- src/helpers/ArticleHelper.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/helpers/ArticleHelper.ts b/src/helpers/ArticleHelper.ts index 40861661..ead20979 100644 --- a/src/helpers/ArticleHelper.ts +++ b/src/helpers/ArticleHelper.ts @@ -656,16 +656,19 @@ export class ArticleHelper { } } - const regex = new RegExp(`{{${placeholder.id}}}`, 'g'); - let updatedValue = filePath - ? await processArticlePlaceholdersFromPath(placeHolderValue, filePath) - : placeHolderValue; + let updatedValue = placeHolderValue; + + // Check if the file already exists, during creation it might not exist yet + if (filePath && (await existsAsync(filePath))) { + updatedValue = await processArticlePlaceholdersFromPath(placeHolderValue, filePath); + } updatedValue = processTimePlaceholders(updatedValue, dateFormat); if (value === `{{${placeholder.id}}}`) { value = updatedValue; } else { + const regex = new RegExp(`{{${placeholder.id}}}`, 'g'); value = value.replace(regex, updatedValue); } } catch (e) {