mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-08 09:53:20 +02:00
Fix: Prevent unwanted automatic updates to publishDate field on save
Co-authored-by: estruyf <2900833+estruyf@users.noreply.github.com>
This commit is contained in:
@@ -502,7 +502,9 @@ export class ArticleHelper {
|
||||
*/
|
||||
public static async updateDates(article: ParsedFrontMatter) {
|
||||
const contentType = await ArticleHelper.getContentType(article);
|
||||
const dateFields = contentType.fields.filter((field) => field.type === 'datetime');
|
||||
const dateFields = contentType.fields.filter(
|
||||
(field) => field.type === 'datetime' && !field.isPublishDate
|
||||
);
|
||||
|
||||
for (const dateField of dateFields) {
|
||||
if (article?.data[dateField.name]) {
|
||||
|
||||
@@ -40,7 +40,10 @@ export const Engines = {
|
||||
return toml.parse(value);
|
||||
},
|
||||
stringify: (value: any) => {
|
||||
return toml.stringify(value);
|
||||
const result = toml.stringify(value);
|
||||
// Preserve the original datetime format by removing unnecessary zero milliseconds
|
||||
// e.g. 2025-09-12T10:00:00.000Z -> 2025-09-12T10:00:00Z
|
||||
return result.replace(/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.000([Z+-][\d:]*)?\b/g, '$1$2');
|
||||
}
|
||||
},
|
||||
yaml: {
|
||||
|
||||
Reference in New Issue
Block a user