Skip to content

Commit 88e446f

Browse files
authored
doc(SourceCodePath): add SourceCodePath configuration section (#5602)
1 parent c35a0a9 commit 88e446f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/BootstrapBlazor.Server/Services/CodeSnippetService.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ namespace BootstrapBlazor.Server.Services;
1414
/// <param name="factory"></param>
1515
/// <param name="cacheManager"></param>
1616
/// <param name="options"></param>
17+
/// <param name="configuration"></param>
1718
/// <param name="localizerOptions"></param>
1819
class CodeSnippetService(
1920
IHttpClientFactory factory,
2021
ICacheManager cacheManager,
2122
IOptions<WebsiteOptions> options,
23+
IConfiguration configuration,
2224
IOptions<JsonLocalizationOptions> localizerOptions)
2325
{
2426
/// <summary>
@@ -88,7 +90,7 @@ private async Task<string> ReadFileAsync(string fileName)
8890
string? payload;
8991
var file = options.Value.IsDevelopment
9092
? $"{options.Value.ContentRootPath}\\..\\BootstrapBlazor.Server\\Components\\Samples\\{fileName}"
91-
: $"{options.Value.SourceCodePath}BootstrapBlazor.Server\\Components\\Samples\\{fileName}";
93+
: $"{GetSourceCodePath()}BootstrapBlazor.Server\\Components\\Samples\\{fileName}";
9294
if (!OperatingSystem.IsWindows())
9395
{
9496
file = file.Replace('\\', '/');
@@ -104,6 +106,8 @@ private async Task<string> ReadFileAsync(string fileName)
104106
return payload;
105107
}
106108

109+
private string GetSourceCodePath() => $"{configuration.GetValue<string>("SourceCodePath") ?? options.Value.SourceCodePath}";
110+
107111
private static string ReplaceSymbols(string payload) => payload
108112
.Replace("@@", "@")
109113
.Replace("&lt;", "<")

0 commit comments

Comments
 (0)