Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
farmerau opened this issue Jan 3, 2022 · 8 comments
Closed

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

farmerau opened this issue Jan 3, 2022 · 8 comments
Labels
bug Something isn't working enhancement New feature or request
Projects
Milestone

Comments

@farmerau
Copy link
Contributor

farmerau commented Jan 3, 2022

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.

@zivbk1
Copy link

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

@farmerau
Copy link
Contributor Author

farmerau commented Jan 3, 2022

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

@estruyf
Copy link
Owner

estruyf commented 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.

@estruyf estruyf added bug Something isn't working enhancement New feature or request labels Jan 4, 2022
@estruyf estruyf added this to In progress in v5.10.0 Jan 4, 2022
@estruyf
Copy link
Owner

estruyf commented Jan 4, 2022

@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
Copy link
Contributor Author

farmerau commented Jan 4, 2022

@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
Copy link
Owner

estruyf commented 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
Copy link
Contributor Author

farmerau commented Jan 4, 2022 via email

@estruyf estruyf moved this from In progress to Done in v5.10.0 Jan 5, 2022
@estruyf estruyf added this to the 5.10.0 milestone Jan 7, 2022
@estruyf estruyf mentioned this issue Jan 10, 2022
@estruyf
Copy link
Owner

estruyf commented Jan 10, 2022

Released in v5.10.0

@estruyf estruyf closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
No open projects
Development

No branches or pull requests

3 participants