Enhancement: Support Creation of "new" .mdx content items #173

Closed
opened 2026-10-05 02:31:08 +02:00 by adam · 8 comments
Owner

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 @zivbk1 here.
  • Respecting the file extension for template files per @zivbk1 here

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.

**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](https://github.com/estruyf/vscode-front-matter/blob/main/src/helpers/ArticleHelper.ts#L206-L209), the `createContent` method hard-codedly decides that the file extension should be ".md". Similarly, this [happens in template generation](https://github.com/estruyf/vscode-front-matter/blob/4d38a0881a9d43a4c1b4432c368618fa4590b844/src/commands/Template.ts#L86) 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 @zivbk1 [here](https://github.com/estruyf/vscode-front-matter/issues/218#issuecomment-1004318876). - Respecting the file extension for template files per @zivbk1 [here](https://github.com/estruyf/vscode-front-matter/issues/218#issuecomment-1004318876) **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. <!-- github-sync-id:1092767653 -->
adam closed this issue 2026-10-05 02:31:08 +02:00
Author
Owner

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/templates folder.
https://frontmatter.codes/docs/content-types#creating-a-template

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/templates` folder. https://frontmatter.codes/docs/content-types#creating-a-template <!-- github-comment-id:1004318876 -->
Author
Owner

@zivbk1 I agree that these are also great alternatives. Updated description.

@zivbk1 I agree that these are also great alternatives. Updated description. <!-- github-comment-id:1004320939 -->
Author
Owner

@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 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. <!-- github-comment-id:1004679576 -->
Author
Owner

@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.

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

Info: In order to use the beta, you have to uninstall the main version. Nothing will be lost, it is just a limitation of VS Code.

@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. 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 > **Info**: In order to use the beta, you have to uninstall the main version. Nothing will be lost, it is just a limitation of VS Code. <!-- github-comment-id:1004714712 -->
Author
Owner

@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:

frontmatter.content.fmHighlight with tooltip

The new setting:
frontMatter.content.defaultFileType with no tooltip

Thanks for the super quick turnaround on this-- I'd totally be happy to contribute in the future.

@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: ![frontmatter.content.fmHighlight with tooltip](https://user-images.githubusercontent.com/5827236/148123093-68aed76f-795a-4e0e-9a6d-0f60119b43e2.jpeg) The new setting: ![frontMatter.content.defaultFileType with no tooltip](https://user-images.githubusercontent.com/5827236/148123197-e93a1c9c-6920-4217-bddc-2a5923b6ad7a.jpeg) Thanks for the super quick turnaround on this-- I'd totally be happy to contribute in the future. <!-- github-comment-id:1005166576 -->
Author
Owner

That is normal, as the documentation and site still need to be updated. Will be for when I finalize the next release.

That is normal, as the documentation and site still need to be updated. Will be for when I finalize the next release. <!-- github-comment-id:1005177364 -->
Author
Owner

Ah, okay, this makes sense!

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
https://github.com/estruyf/vscode-front-matter/issues/218#issuecomment-1005177364,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABMOVJHCG75HGFB7PDXAULTUUNPZJANCNFSM5LF3YEWQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

Ah, okay, this makes sense! 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 > <https://github.com/estruyf/vscode-front-matter/issues/218#issuecomment-1005177364>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ABMOVJHCG75HGFB7PDXAULTUUNPZJANCNFSM5LF3YEWQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> > <!-- github-comment-id:1005178087 -->
Author
Owner

Released in v5.10.0

Released in `v5.10.0` <!-- github-comment-id:1008807940 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#173