ignite
ignite copied to clipboard
Add front matter support to templates
Per #1611 templates currently only support copying their contents to app directories with a pluralized name of the template directory. Since ignite puts navigators in the app/navigation directory we need a way to customize this.
By using front matter we can specify a destinationDir at the top of the template, customizing per template file. This also opens up the possibility for more powerful generator customization in the future.
Thanks for this PR, @kateinkim! It's super well done.
So, #1629 addresses the current problem, which is the navigation / navigators naming issue brought up in #1611.
I like the idea of frontmatter in general. However, I'm putting this PR "on hold" for now until we see another situation where it will be directly useful. I'll keep it open.
One note: I don't want to use gray-matter. If we can use a different frontmatter library that would be good. I don't want Ignite associated with the author of that library.
Thanks @jamonholmgren! I'll get the library updated.
@kateinkim We already have the yaml library in our dependencies. I'm sorta considering us rolling our own frontmatter ... basically, see if the file contains two lines that are just ---, and if so, parse what's between as yaml, and remove that chunk for rendering purposes. Just thinking out loud, though -- if you find a good (small) frontmatter library that might be all we need.
@jamonholmgren I updated to remove the gray-matter dependency and added support for patching from templates. I added patches to the model template to automatically import and add stores to the root store.
Hey @jamonholmgren! I updated to support append, prepend, and replace as well and refactored the existing barrel export handling with it (still supports the skipping option). I also moved the patching handling out into it's own function. Let me know what you think.
Would this PR also allow us to create a custom generator for api? The folder structure would be to place the generated 'api' files within the services/api sub-directory of app?
@gavinharris-dev Yes! You’d be able to target any path in the project. 🙂
@kateinkim When you get a chance, can you resolve conflicts on this? No rush.
@kateinkim When you get a chance, can you resolve conflicts on this? No rush.
Yep! I will take a look at this later today!
Whoa, it took long time to remember what and how I did this thing after coming back a year later. It's all tested and working now! 😄
Since this is working, let's target v8: Maverick for this @kateinkim. Can you resolve conflicts and re-target this at the maverick branch?
Well, It wasn't easy to fix the conflicts but it's working as it is supposed to be still. @jamonholmgren