Issue: Automatic DateTime Updates (lastmod) Requires Additional Extensions for MDX Files
See original GitHub issueDescribe the bug
Despite “Auto-update modified date” being enabled in frontmatter.json, the lastmod
field isn’t updated for MDX files unless an additional extension is installed, like MDX on the marketplace.
To Reproduce Steps to reproduce the behavior:
- Ensure the
frontMatter.content.autoUpdateDate
setting is set to true and no language support installed (or enabled) on VS Code. - Use a block like this in your mdx file:
---
title: Sample Title
date: '2022-01-03T19:26:06.826Z'
lastmod: '2022-01-03T19:26:06.826Z'
---
- Update the content as you would in the editor.
- Observe that the lastmod property is not updated Note: The FrontMatter extension parses this block just fine, and if I explicitly click it to set the value, it does behave properly.
Expected behavior One extension probably shouldn’t depend on the presence of another to function, unless otherwise explicitly deemed necessary. I’d expect the plugin to update the lastmod value regardless of the language support being installed (this may be wrong of me to expect).
Screenshots N/A
VS Code Version
Version: 1.63.2 (Universal)
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:37:28.172Z (2 wks ago)
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 21.2.0
Extension Version
v5.9.0
Additional context
isMarkdownFile
in ArticleHelper
(seen here) expects the language to be identified. MDX isn’t supported out-of-the-box with VS Code-- meaning that for this method to work it requires installing another extension for this extension to support it.
I’m torn about whether or not this behavior makes sense-- I could understand arguments either way. If we wanted to support this without requiring the extension, we could check the file extension as one way to determine if it is a mdx file.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top GitHub Comments
@estruyf In further digging, there are two primary ways to handle this that I can see:
extensionDependencies
.TextDocument.fileName
as a fallback inisMarkdownFile
when we check to see if the file belongs to one of the supported languages.I admittedly don’t have a lot of practice with VS Code extensions, so I’m not sure what the best practice would be in this case.
My gut leans towards number 2, primarily because I anticipate MDX is the exceptional use-case and it doesn’t seem fair to ask users to install an extension that they might not be using in reality.
@farmerau it is now available in the beta version