Skip to content

Commit aad96d0

Browse files
committed
Use new contrib methods to add static resources.
1 parent 808873c commit aad96d0

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

src/Samples/PartialStaticSite/Program.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define ENABLE_STATIC_PAGE_FALLBACK
22

33
using AspNetStatic;
4+
using AspNetStaticContrib.AspNetStatic;
45
using Microsoft.Extensions.Hosting;
56
using PartialStaticSite;
67

@@ -18,7 +19,11 @@
1819
builder.Services.AddRazorPages();
1920

2021
builder.Services.AddSingleton<IStaticResourcesInfoProvider>(
21-
new StaticResourcesInfoProvider(SampleStaticPages.GetCollection()));
22+
new StaticResourcesInfoProvider(SampleStaticPages.GetCollection())
23+
.Add(builder.Environment.GetWebRootCssResources(["**/site.css", "**/*.min.css"]))
24+
.Add(builder.Environment.GetWebRootJsResources())
25+
.Add(builder.Environment.GetWebRootBinResources(["**/*.ico"]))
26+
);
2227

2328
// Use the "no-ssg" arg to omit static file generation
2429
// during development (hot-reload, etc.)
@@ -72,19 +77,20 @@
7277

7378
app.UseRouting();
7479

80+
app.UseAuthentication();
7581
app.UseAuthorization();
7682

7783
app.MapRazorPages();
7884

7985
if (allowSSG)
8086
{
8187
app.GenerateStaticContent(
82-
app.Environment.WebRootPath,
83-
exitWhenDone: exitWhenDone,
84-
alwaysDefaultFile: false,
85-
dontUpdateLinks: false,
86-
dontOptimizeContent: false,
87-
regenerationInterval: regenInterval);
88+
app.Environment.WebRootPath,
89+
exitWhenDone: exitWhenDone,
90+
alwaysDefaultFile: false,
91+
dontUpdateLinks: false,
92+
dontOptimizeContent: false,
93+
regenerationInterval: regenInterval);
8894
}
8995

9096
app.Run();

src/Samples/PartialStaticSite/Sample.PartialStaticSite.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14+
<ProjectReference Include="..\..\AspNetStaticContrib\AspNetStaticContrib.csproj" />
1415
<ProjectReference Include="..\..\AspNetStatic\AspNetStatic.csproj" />
1516
</ItemGroup>
1617

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
using AspNetStatic;
22

3-
namespace PartialStaticSite
3+
namespace PartialStaticSite;
4+
5+
public static class SampleStaticPages
46
{
5-
public static class SampleStaticPages
6-
{
7-
public static IEnumerable<PageResource> GetCollection() =>
8-
new PageResource[]
9-
{
10-
new("/"),
11-
new("/") { Query = "?p1=v1", OutFile = "index-p1v1.htm" },
12-
new("/123") { OutFile = "index-123.htm" },
13-
new("/123") { Query = "?p1=v1", OutFile = "index-123-p1v1.htm" },
14-
new("/Privacy"),
15-
new("/Blog/Articles/"),
16-
new("/Blog/Articles/Article1"),
17-
new("/Blog/Posts/1") { OutFile = @"blog\post1.htm" },
18-
};
19-
}
7+
public static IEnumerable<PageResource> GetCollection() =>
8+
[
9+
new("/"),
10+
new("/") { Query = "?p1=v1", OutFile = "index-p1v1.htm" },
11+
new("/123") { OutFile = "index-123.htm" },
12+
new("/123") { Query = "?p1=v1", OutFile = "index-123-p1v1.htm" },
13+
new("/Privacy"),
14+
new("/Blog/Articles/"),
15+
new("/Blog/Articles/Article1"),
16+
new("/Blog/Posts/1") { OutFile = @"blog\post1.htm" },
17+
];
2018
}

0 commit comments

Comments
 (0)