statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.64k stars 235 forks source link

Generate multiple html from one razor #938

Open biologist9675 opened 3 years ago

biologist9675 commented 3 years ago

Hi,

I am mostly familiar with MVC and Web Forms. Trying to understand this great framework better and how to compose custom pipelines. I have a giant list of data loaded from the database using ReadDataModule. I want to pass subsets/chunks of this data to the same razor .cshtml and generate multiple html pages. Each html output page will be dynamically named based on some of the input data. I am trying to write a custom pipeline below to pass the chunks to the razor template multiple times, but having trouble understanding how to do this. Any help is appreciated.

public class TestPipeline : Pipeline
{
    public TestPipeline()
    {
        InputModules = new ModuleList
        {
            new ReadFiles("TestTemplate.cshtml")
        };

        ProcessModules = new ModuleList
        {
            new RenderRazor()
        };

        OutputModules = new ModuleList
        {
            new WriteFiles()
        };
    }
}
daveaglick commented 2 years ago

Hey there, sorry for the extremely late reply. I'm catching up on the issues I managed to miss over the last year.

Are you still working on this and need help on how to do it, or were you able to figure it out? Let me know and I'll work up an example if you still need one.