This PR adds support for a transpiler/ directory where you can define custom transpilers (e.g. .md to .html).
This generator is low-level and meant to allow you to hook custom transpilers into other higher-level generators, like the view generator or the public generator. By decoupling transpiling from those generators, it can be used anywhere you need to change from one file format to another, including your custom generators.
Some use cases include:
.svelte to .svelte: where the class names are run through Tailwind's JIT compiler.
.md to .html: where markdown gets converted into Svelte
.svg to .svg: where you run the svgo optimizer in production for your SVG images in the public/ directory.
Here's how you could define a custom transpiler in transpiler/md/md.go(untested):
This will define a custom transpiler in that will get triggered whenever you request an HTML file from a Markdown file. As I mentioned, this won't write any files, it's meant to be used by other generators.
In a subsequent PR, the view generator will hook up the transpiler generator, but you could also trigger this from a custom generator in generator/static/static.go:
Now when bud run or bud build is called, you'll end up with a bud/internal/static/index.html file containing the transpiled version of view/index.md into HTML.
This PR adds support for a
transpiler/
directory where you can define custom transpilers (e.g..md
to.html
).This generator is low-level and meant to allow you to hook custom transpilers into other higher-level generators, like the view generator or the public generator. By decoupling transpiling from those generators, it can be used anywhere you need to change from one file format to another, including your custom generators.
Some use cases include:
.svelte
to.svelte
: where the class names are run through Tailwind's JIT compiler..md
to.html
: where markdown gets converted into Svelte.svg
to.svg
: where you run the svgo optimizer in production for your SVG images in the public/ directory.Here's how you could define a custom transpiler in
transpiler/md/md.go
(untested):This will define a custom transpiler in that will get triggered whenever you request an HTML file from a Markdown file. As I mentioned, this won't write any files, it's meant to be used by other generators.
In a subsequent PR, the view generator will hook up the transpiler generator, but you could also trigger this from a custom generator in
generator/static/static.go
:Now when
bud run
orbud build
is called, you'll end up with abud/internal/static/index.html
file containing the transpiled version ofview/index.md
into HTML.Todo: