Multiple question about Features
Closed this issue · 2 comments
First of all, thank you for this library. It is a nice idea I was looking for for a long time.
I am trying AspNetStatic with .NET 8 with the Blazor approach. That way I can use Blazor components for building static website - what a dream. It all works, almost no extra setup is needed. Great.
I have few questions and ideas about what is possible:
Input pages without specifying them
currently we have this:
builder.Services.AddSingleton<IStaticPagesInfoProvider>(
new StaticPagesInfoProvider(
new PageInfo[]
{
new("/") { OutFile = "index.html" },
new("/app.css") { OutFile = "app.css"},
})
);
Is it possible to have something like:
builder.Services.AddSingleton<IStaticPagesInfoProvider>(
new StaticPagesInfoProvider(
ConvertAllPagesBaseOnPageDirective = true)
);
That would simplify things..
Copy files and folders
As you can see, I am using the PageInfo to copy app.css
file. It works ok for text files, but not so much for images.
It would be cool to be able to:
new("wwwroot") { JustCopy = true, Recursive = true},
I know the path is the path for web app, not the file system, but you got the idea.
File generation middleware
It would be useful to be able to "do something" with file before it is saved.
I can help with those if necessary. But I am curious if not missing something.
Thank you!
Hello, @tesar-tech. Thank you for the positive feedback. It's much appreciated.
Input pages without specifying them
Why not just write a helper method that returns a PageInfo
collection containing the desired pages based on whatever criteria you have in mind? Or, if it's a more complex operation, create a custom StaticPagesInfoProvider (derived from StaticPagesInfoProvider
or StaticPagesInfoProviderBase
). Indeed, a custom StaticPagesInfoProvider for what you describe might be an interesting PR, if you were so inclined ;-)
Copy files and folders
This is not really the intent/purpose of AspNetStatic. For copying files (img, css, js, etc.) to the destination (published) folder, I would recommend creating a Gulp function and hooking it up in Task Runner to be executed before/after a build.
File generation middleware
This is interesting. Would it suffice to call a user-supplied action method (after all static files have been generated) and passing to it the pathnames of the generated files? Or did you have something else in mind?
Thanks again for the feedback, @tesar-tech. I will definitely keep these suggestions in mind, but I'm closing this issue due to inactivity.