conficient / BlazorTemplater

A library that generates HTML (e.g. for emails) from Razor Components
Apache License 2.0
146 stars 16 forks source link

Static site generator #15

Closed ElderJames closed 2 years ago

ElderJames commented 3 years ago

This is a great project, is there any intention to make a document publishing tool that can generate a static site?

The html file can be generated by reading the accessible URL route on the page.

conficient commented 3 years ago

That's not something I'd considered, can you explain why/how this might be used?

conficient commented 2 years ago

I had a quick go at figuring out what's required. The current API for Templater in BlazorTemplater uses generics, so you would call .RenderComponent<TComponent> - except that if we're scanning for components with @page routes we'd be getting the Type and cannot use this method. I'd need to add an overload of .RenderComponent(Type componentType) which wouldn't be too hard.

The process would not be able to handle any pages with route templates containing parameters, since these would be dynamic by definition: e.g. @page "/customer/{id}" would not work.

conficient commented 2 years ago

I've created an experimental repo BlazorTemplater-StaticDemo to try this scenario out. It works at a basic level but there are a lot of things that would need to be changed/fixed to use as a site generator. Feel free to use my repo as a guide. I won't be adding this functionality to BlazorTemplater as it would be feature bloat. I'll close this as there is now a route should you wish to explore it.