From e8dc87adfe1c3ad77d3d60d147e2bc2104d91ad1 Mon Sep 17 00:00:00 2001 From: delphi Date: Mon, 26 May 2025 16:16:00 +0800 Subject: [PATCH] fix: time format template is not effective --- src/templateProcessor.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/templateProcessor.ts b/src/templateProcessor.ts index 836e02b..bef7530 100644 --- a/src/templateProcessor.ts +++ b/src/templateProcessor.ts @@ -128,6 +128,16 @@ export class TemplateProcessor { frontMatter[alias] = article.tags; continue; } + + if (variable === 'create_time' && article.create_time) { + frontMatter[alias] = formatDateTime(article.create_time, this.dateFormat); + continue; + } + + if (variable === 'update_time' && article.update_time) { + frontMatter[alias] = formatDateTime(article.update_time, this.dateFormat); + continue; + } const value = this.getArticleProperty(article, variable); if (value) { @@ -185,8 +195,8 @@ export class TemplateProcessor { highlights: [], tags: article.tags || [], highlights_length: article.highlights?.length || 0, - formatted_create_time: article.create_time ? formatDateTime(article.create_time, this.dateFormat) : '', - formatted_update_time: article.update_time ? formatDateTime(article.update_time, this.dateFormat) : '' + create_time: article.create_time ? formatDateTime(article.create_time, this.dateFormat) : '', + update_time: article.update_time ? formatDateTime(article.update_time, this.dateFormat) : '' }; // 处理高亮内容 @@ -238,7 +248,7 @@ export class TemplateProcessor { ...highlight, text: text, note: note, - formatted_create_time: highlight.create_time ? formatDateTime(highlight.create_time, this.dateFormat) : '' + create_time: highlight.create_time ? formatDateTime(highlight.create_time, this.dateFormat) : '', }; // 确保所有必要的字段都存在