Skip to content

Commit

Permalink
Update config key for PrefersColorScheme header name
Browse files Browse the repository at this point in the history
Updated the configuration key from `PrefersColorScheme:HeaderName`
to `PrefersColorSchemeHeader:HeaderName` in the following files:
- PrefersColorSchemeMiddleware.cs
- _Layout.cshtml
- _LayoutAdmin.cshtml

This change ensures the application reads the header name from
the updated configuration section.
  • Loading branch information
EdiWang committed Oct 9, 2024
1 parent b151bc2 commit 23b78ac
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class PrefersColorSchemeMiddleware(RequestDelegate next)
{
public async Task InvokeAsync(HttpContext context, IConfiguration configuration)
{
var headerName = configuration["PrefersColorScheme:HeaderName"];
var headerName = configuration["PrefersColorSchemeHeader:HeaderName"];
if (string.IsNullOrWhiteSpace(headerName))
{
await next(context);
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Web/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// This is to enhance user experience by stopping the screen from blinking when switching pages
bool useServerSideDarkMode = false;
bool usePrefersColorSchemeHeader = Configuration.GetSection("PrefersColorSchemeHeader:Enabled").Get<bool>();
var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorScheme:HeaderName"]!];
var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorSchemeHeader:HeaderName"]!];
if (usePrefersColorSchemeHeader && prefersColorScheme == "dark")
{
useServerSideDarkMode = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Web/Pages/Shared/_LayoutAdmin.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// This is to enhance user experience by stopping the screen from blinking when switching pages
bool useServerSideDarkMode = false;
bool usePrefersColorSchemeHeader = Configuration.GetSection("PrefersColorSchemeHeader:Enabled").Get<bool>();
var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorScheme:HeaderName"]!];
var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorSchemeHeader:HeaderName"]!];
if (usePrefersColorSchemeHeader && prefersColorScheme == "dark")
{
useServerSideDarkMode = true;
Expand Down

0 comments on commit 23b78ac

Please sign in to comment.