Skip to content

Commit 2812103

Browse files
authored
Update Readme.md
1 parent fd3e01f commit 2812103

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

Readme.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Just add this package and tell it which routes (page, css, js, etc.) to process.
2424

2525
AspNetStatic works equally well with Blazor (SSR), Razor Pages, and MVC (controllers + views).
2626

27-
> :bulb: Blazor pages must not rely on any client-side (JS, WASM) functionality for rendering, or any behaviors like showing a placeholder (e.g. a spinner) before rendering the actual content.
27+
<!-- :bulb: -->
28+
> [!Important]
29+
> Blazor pages must not rely on any client-side (JS, WASM) functionality for rendering, or any behaviors like showing a placeholder (e.g. a spinner) before rendering the actual content.
2830
> The rule-of-thumb (for any tech you want to use with AspNetStatic) is that as long as the content has completed rendering by the time AspNetStatic receives it (via http request), then it will work fine.
2931
3032
#### But wait, there's more!
@@ -120,12 +122,15 @@ Keep the following in mind when specifying routes in the `IStaticResourcesInfoPr
120122
- You can skip content optimization<sup>1</sup> or choose a specific optimization type for routes you add to the `PageResources` collection (see `OptimizationType` property). The default optimization type setting, `OptimizationType.Auto`, automatically applies the appropriate optimization.
121123
- You can set the encoding for content written to output files for routes you add to the `PageResources` collection (see `OutputEncoding` property). Default is UTF8.
122124

123-
> :bulb: All of the above also applies to routes for CSS, JavaScript, and binary (e.g. image) files specified in the `OtherResources` collection property.
124-
125+
> [!Note]
125126
> 1: Content optimization options apply only when content optimization is enabled. Please see the __Content Optimization__ section below for details.
126127
128+
> [!Tip]
129+
> All of the above also applies to routes for CSS, JavaScript, and binary (e.g. image) files specified in the `OtherResources` collection property.
130+
127131
### Routes vs. Generated Static Files (page resources)
128132

133+
> [!Note]
129134
> #### Assumes the following:
130135
> - Resource Type: PageResource
131136
> - Destination root: "__C:\MySite__"
@@ -147,6 +152,7 @@ Url<br/>(route + query) | Always Default<br/>false | Always Default<br/>true
147152

148153
### Routes vs. Generated Static Files (non-page resources)
149154

155+
> [!Note]
150156
> #### Assumes the following:
151157
> - Resource Type: __CssResource__, __JsResource__, or __BinResource__
152158
> - Destination root: "__C:\MySite__"
@@ -174,6 +180,7 @@ Url<br/>(route + query) | Generated File
174180

175181
### Fallback Middleware: Routes vs. Served Content
176182

183+
> [!Note]
177184
> #### Assumes the following:
178185
> - OutFile: __null, empty, or whitespace__
179186
> - Applicable only to __PageResource__ items.
@@ -193,10 +200,11 @@ Url<br/>(route + query) | Is Static Route: false<br/><br/> | Is Static Route: tr
193200
/blog/articles/post1 | /blog/articles/post1.cshtml | /blog/articles/post1.html | /blog/articles/post1/index..html
194201

195202

196-
> :bulb: The same rules apply when links in static files are updated to refer to other generated static pages.
197-
203+
> [!Tip]
204+
> The same rules apply when links in static files are updated to refer to other generated static pages.
198205
199-
__IMPORTANT NOTE__: In ASP.NET Core, UrlHelper (and the asp-* tag helpers) generate link URIs based on the routing configuration of your app, so if you're using them, be sure to specify an appropriate value for `alwaysDefaultFile`, as shown below. (NOTE: Specify the same value if/when configuring the fallback middleware).
206+
> [!Important]
207+
In ASP.NET Core, UrlHelper (and the asp-* tag helpers) generate link URIs based on the routing configuration of your app, so if you're using them, be sure to specify an appropriate value for `alwaysDefaultFile`, as shown below. (NOTE: Specify the same value if/when configuring the fallback middleware).
200208
```c#
201209
// Sample routes: /, /index, and /page
202210
//-------------------------------------
@@ -245,7 +253,8 @@ app.GenerateStaticContent(
245253

246254
## Scenarios
247255

248-
> :bulb: In all scenarios, ensure that routes for static content are unincumbered by authentication or authorization requirements.
256+
> [!Important]
257+
> In all scenarios, please ensure that routes for static content are unincumbered by authentication or authorization requirements or anything else that requires user interaction.
249258
250259
### Static Site Generation (Standalone SSG)
251260

@@ -309,7 +318,8 @@ Now you can use the SSG profile to launch your app in SSG mode (to generate stat
309318

310319
In this scenario, you want some of the pages in your ASP.NET Core app to be static, but still want other routes to be served as dynamic content per request (e.g. pages/views, JSON API's, etc.). When the app runs, static (.html) files will be generated for routes you specify. The website will then serve these static files for the specified routes, and dynamic content (as usual) for others.
311320

312-
> :bulb: While static files are being generated, requests to routes for which a static file has not yet been generated will be served as dynamicly generated content (using the source .cshtml page). Once the static file for that route has been generated, it will be used to satisfy subsequent requests.
321+
> [!Note]
322+
> While static files are being generated, requests to routes for which a static file has not yet been generated will be served as dynamicly generated content (using the source .cshtml page). Once the static file for that route has been generated, it will be used to satisfy subsequent requests.
313323
314324
The configuration options are generally the same as for a standalone static site, except the following differences:
315325
- The destination root folder must be `app.Environment.WebRoot` (i.e. wwwroot).
@@ -339,7 +349,8 @@ app.GenerateStaticContent(
339349
app.Run();
340350
```
341351

342-
> :bulb: The fallback middleware only re-routes requests for routes that match entries in the `PageResources` collection, and only if a generated static file exists for that route.
352+
> [!Note]
353+
> The fallback middleware only re-routes requests for routes that match entries in the `PageResources` collection, and does so only if a generated static file exists for that route.
343354
344355

345356
#### Periodic Regeneration
@@ -381,7 +392,8 @@ An `IOptimizerSelector` implementation can select an optimizer based on the attr
381392

382393
`DefaultOptimizerSelector` uses the resource type and `OptimizationType` information to select an optimizer.
383394

384-
> :bulb: If a given resource requests no optimization (`OptimizationType.None`), or an optimizer implementation is not available for that resource type, `DefaultOptimizerSelector` will return one of the built-in "null" optimizers (`NullMarkupOptimizer`, `NullCssOptimizer`, `NullJsOptimizer`, and `NullBinOptimizer`).
395+
> [!Note]
396+
> If a given resource requests no optimization (`OptimizationType.None`), or an optimizer implementation is not available for that resource type, `DefaultOptimizerSelector` will return one of the built-in "null" optimizers (`NullMarkupOptimizer`, `NullCssOptimizer`, `NullJsOptimizer`, and `NullBinOptimizer`).
385397
386398
To use your own custom selector, implement the `IOptimizerSelector` interface and register it in the DI container.
387399

@@ -400,7 +412,8 @@ builder.Services.AddDefaultOptimizers(); // register default optimizers & minifi
400412
builder.Services.AddSingleton<IJsMinifier, YuiJsMinifier>(); // override default minifier
401413
builder.Services.AddSingleton<IMarkupOPtimizer, MyCustomMarkupOptimizer>()); // override default optimizer
402414
```
403-
> :bulb: If your custom `IOptimizerSelector` implementation injects one or more of the default optimizers provided by AspNetStatic, you must register them by calling `AddDefaultOptimizers()`.
415+
> [!Important]
416+
> If your custom `IOptimizerSelector` implementation injects one or more of the default optimizers provided by AspNetStatic, you must register them by calling `AddDefaultOptimizers()`.
404417
405418

406419
### Optimizers
@@ -480,7 +493,9 @@ builder.Services.AddDefaultMinifiers();
480493
The default optimizers provided by AspNetStatic (`DefaultMarkupOptimizer`, `DefaultCssOptimizer`, and `DefaultJsOptimizer`) use the `WebMarkupMin` package to minify HTML, CSS and JS content.
481494
To override the default minification settings used by AspNetStatic, register the appropriate objects as described below.
482495

483-
> :flashlight: For details about WebMarkupMin configuration settings, please consult the [WebMarkupMin documentation](https://github.com/Taritsyn/WebMarkupMin/wiki/).
496+
<!-- :flashlight: -->
497+
> [!Tip]
498+
> For details about WebMarkupMin configuration settings, please consult the [WebMarkupMin documentation](https://github.com/Taritsyn/WebMarkupMin/wiki/).
484499
485500
AspNetStatic uses the default `WebMarkupMin` configuration settings (_determined internally by WebMarkupMin_) for minifying HTML, XHTML, and XML content. To override this behavior, register one or more of the following configuration objects:
486501

0 commit comments

Comments
 (0)