Skip to content

Commit fdfcc59

Browse files
authored
Add livereload to live mode (#93)
1 parent d65070b commit fdfcc59

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/docs-builder/Http/DocumentationWebHost.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.Extensions.FileProviders;
1313
using Microsoft.Extensions.Hosting;
1414
using Microsoft.Extensions.Logging;
15+
using Westwind.AspNetCore.LiveReload;
1516

1617
namespace Documentation.Builder.Http;
1718

@@ -30,6 +31,11 @@ public DocumentationWebHost(string? path, ILoggerFactory logger, IFileSystem fil
3031
{
3132
Collector = new ConsoleDiagnosticsCollector(logger)
3233
};
34+
builder.Services.AddLiveReload(s =>
35+
{
36+
s.FolderToMonitor = context.SourcePath.FullName;
37+
s.ClientFileExtensions = ".md,.yml";
38+
});
3339
builder.Services.AddSingleton<ReloadableGeneratorState>(_ => new ReloadableGeneratorState(sourcePath, null, context, logger));
3440
builder.Services.AddHostedService<ReloadGeneratorService>();
3541
builder.Services.AddSingleton(logger);
@@ -39,10 +45,12 @@ public DocumentationWebHost(string? path, ILoggerFactory logger, IFileSystem fil
3945
SetUpRoutes();
4046
}
4147

48+
4249
public async Task RunAsync(Cancel ctx) => await _webApplication.RunAsync(ctx);
4350

4451
private void SetUpRoutes()
4552
{
53+
_webApplication.UseLiveReload();
4654
_webApplication.UseStaticFiles(new StaticFileOptions
4755
{
4856
FileProvider = new PhysicalFileProvider(_staticFilesDirectory),

src/docs-builder/docs-builder.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<PackageReference Include="Errata" Version="0.13.0" />
2828
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
2929
<PackageReference Include="Github.Actions.Core" Version="8.1.1"/>
30+
<PackageReference Include="Westwind.AspNetCore.LiveReload" Version="0.5.0" />
3031
</ItemGroup>
3132

3233
<ItemGroup>

0 commit comments

Comments
 (0)