You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement: Support Creation of "new" .mdx content items #218
Is your feature request related to a problem? Please describe.
As someone who exclusively uses MDX for content creation (as well as FrontMatter) I'm frustrated when creating new content because I need to change the file extension manually to support my workflow-- despite the plugin generally supporting FrontMatter in MDX files.
Describe the solution you'd like
In ArticleHelper, the createContent method hard-codedly decides that the file extension should be ".md". Similarly, this happens in template generation as well.
I'd propose this be determined via a frontmatter setting.
Describe alternatives you've considered
Manually changing the file extension on my own every time I create new content (not preferred)
Creating a field to the content type template definitions in frontMatter.taxonomy.contentTypes per @zivbk1here.
Respecting the file extension for template files per @zivbk1here
Additional context
I would anticipate a change like this would be fully backwards compatible, as the default extension should remain ".md".
I'm happy to open a PR to address this once there's some buy-in.
It seems like this could be a field in the content type template definition frontMatter.taxonomy.contentTypes.
Adding an 'extension' variable with the string for what the file extension should be for that type.
@farmerau fair point! This should be a configuration by the template from which you create the content or from the content type. This needs to be enhanced on both ends.
@farmerau I have added better mdx support for content creation. Things that changed:
When creating content from a template, it will use the file extension of the template.
When creating content for a content type, it will use the defined file type md | mdx. This is a new property (optional) on the frontMatter.taxonomy.contentTypes setting called fileType.
When creating content for a content type, it will check if it has a defined file type, if not, it uses the new frontMatter.content.defaultFileType setting for the file type to create. This setting is by default set to md, but if you change it to mdx, all new content will be created as mdx files. The benefit of this setting is that you only need to specify it once, and all content types will use it.
@estruyf I pulled the latest Beta down and can confirm setting frontMatter.content.defaultFileType behaved as expected.
One odd thing I noticed is that the documentation for the setting doesn't appear to be loading via tooltip-- I'm not sure if that's due to caching or the way that the beta is built:
For example, a previously existing setting:
The new setting:
Thanks for the super quick turnaround on this-- I'd totally be happy to contribute in the future.
On Tue, Jan 4, 2022 at 4:18 PM Elio Struyf ***@***.***> wrote:
That is normal, as the documentation and site still need to be updated.
Will be for when I finalize the next release.
—
Reply to this email directly, view it on GitHub
<#218 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABMOVJHCG75HGFB7PDXAULTUUNPZJANCNFSM5LF3YEWQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
Activity
zivbk1 commentedon Jan 3, 2022
It seems like this could be a field in the content type template definition
frontMatter.taxonomy.contentTypes.Adding an 'extension' variable with the string for what the file extension should be for that type.
Another option is to respect the file extension for a template file in the
.frontmatter/templatesfolder.https://frontmatter.codes/docs/content-types#creating-a-template
farmerau commentedon Jan 3, 2022
@zivbk1 I agree that these are also great alternatives. Updated description.
estruyf commentedon Jan 4, 2022
@farmerau fair point! This should be a configuration by the template from which you create the content or from the content type. This needs to be enhanced on both ends.
#218 - Added MDX support for template and content creation
estruyf commentedon Jan 4, 2022
@farmerau I have added better
mdxsupport for content creation. Things that changed:md | mdx. This is a new property (optional) on thefrontMatter.taxonomy.contentTypessetting calledfileType.frontMatter.content.defaultFileTypesetting for the file type to create. This setting is by default set tomd, but if you change it tomdx, all new content will be created asmdxfiles. The benefit of this setting is that you only need to specify it once, and all content types will use it.This is now available in the beta version. Feel free to give it a try, and let me know how it works for you. Beta version can be found here: https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter-beta
farmerau commentedon Jan 4, 2022
@estruyf I pulled the latest Beta down and can confirm setting
frontMatter.content.defaultFileTypebehaved as expected.One odd thing I noticed is that the documentation for the setting doesn't appear to be loading via tooltip-- I'm not sure if that's due to caching or the way that the beta is built:
For example, a previously existing setting:
The new setting:

Thanks for the super quick turnaround on this-- I'd totally be happy to contribute in the future.
estruyf commentedon Jan 4, 2022
That is normal, as the documentation and site still need to be updated. Will be for when I finalize the next release.
farmerau commentedon Jan 4, 2022
estruyf commentedon Jan 10, 2022
Released in
v5.10.0