zarehd / aspnetstatic Goto Github PK
View Code? Open in Web Editor NEWTransform ASP.NET Core into a static site generator.
License: Apache License 2.0
Transform ASP.NET Core into a static site generator.
License: Apache License 2.0
Is your feature request related to a problem? Please describe.
I am trying to use this library to generate static pages for vintage devices.
Everything is fine but I met a problem.
I need to convert WebP images to JPG images for WebP images can't be displayed on some devices. But there's no way to do that when using BinResource
.
Describe the solution you'd like
We can add a middleware, so that we can modify resource's content before AspNetStatic
copys resource to the output directory.
For example:
var options = new StaticContentResourceOptions()
{
OnProcessResource = (StaticContentResourceContext context) =>
{
if (context.Url.EndWith(".webp"))
{
Stream resContent = context.ResourceContent;
// Do something here...
}
}
};
app.UseStaticContentResourceProcessing(options);
Describe alternatives you've considered
Instead of using BinResource
, I manually modified file and copied it to the output directory. But this is inconvenient.
Additional context
No
Hi,
is there an invalidation service? e.g. I have webhooks that can be used to refresh the content and I would like to integrate every page.
I am trying to use this library to generate static pages from a razor pages app to host on Github Pages. The problem is that the pages work locally, but not in GP, since it uses www.{username}.github.io/{projectName}/
URL structure. This causes root paths to point to www.{username}.github.io/
I tried using:
var builder = WebApplication.CreateBuilder(new WebApplicationOptions()
{
WebRootPath = "wwwroot/AwesomeProject"
});
and
app.UsePathBase("/projectName");
But it does not seem to do anything. I know Hugo allows to define the project base URL path in config.toml
. Maybe I am missing some builtin functionality, but I don't seem to find a way to solve this currently.
Add support for replacing ~
with a custom BaseURL string for all paths beginning with ~/
.
Hook for programmatic slug generation
Is your feature request related to a problem? Please describe.
It would be nice if you provided some common implementations of IStaticResourcesInfoProvider
Describe the solution you'd like
Using blazor ssr to build websites is now a very nice experience. It would be great to support that quickly out of the box. For example,
a RazorComponentsStaticResourcesInfoProvider
would automatically register all /page
routes and anything in the wwwroot
folder would make getting going with AspNetStatic in that use case really great.
Describe alternatives you've considered
That may be too restrictive so you could move towards a builder pattern that enables you to quickly configure common patterns in to an overall InfoProvider. For example:
var infoProvider = new StaticResourcesInfoProviderBuilder()
.AddRazorComponentPages()
.AddWwwRoot()
.Build();
```
I've not got anything like this working myself yet but happy to contribute back if it seems useful?
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:
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..
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.
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!
Great effort
Describe the bug
There is a typo in the fourth parameter of GenerateStaticPages()
To Reproduce
In file src/AspNetStatic/StaticPageGeneratorHostExtension.cs
The fourth parameter is named as alwaysDefautFile
, this is incorrect.
Expected behavior
The fourth parameter should be named as alwaysDefaultFile
Additional context
No
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.