From 23b78ac950ee84aad4d7b57e036e99cac924e207 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Wed, 9 Oct 2024 15:34:07 +0800 Subject: [PATCH] Update config key for PrefersColorScheme header name 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. --- src/Moonglade.Web/Middleware/PrefersColorSchemeMiddleware.cs | 2 +- src/Moonglade.Web/Pages/Shared/_Layout.cshtml | 2 +- src/Moonglade.Web/Pages/Shared/_LayoutAdmin.cshtml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Moonglade.Web/Middleware/PrefersColorSchemeMiddleware.cs b/src/Moonglade.Web/Middleware/PrefersColorSchemeMiddleware.cs index 2ebbf7b2f..ca2fbb833 100644 --- a/src/Moonglade.Web/Middleware/PrefersColorSchemeMiddleware.cs +++ b/src/Moonglade.Web/Middleware/PrefersColorSchemeMiddleware.cs @@ -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); diff --git a/src/Moonglade.Web/Pages/Shared/_Layout.cshtml b/src/Moonglade.Web/Pages/Shared/_Layout.cshtml index 8b44f6ac6..8d5a26eab 100644 --- a/src/Moonglade.Web/Pages/Shared/_Layout.cshtml +++ b/src/Moonglade.Web/Pages/Shared/_Layout.cshtml @@ -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(); - var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorScheme:HeaderName"]!]; + var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorSchemeHeader:HeaderName"]!]; if (usePrefersColorSchemeHeader && prefersColorScheme == "dark") { useServerSideDarkMode = true; diff --git a/src/Moonglade.Web/Pages/Shared/_LayoutAdmin.cshtml b/src/Moonglade.Web/Pages/Shared/_LayoutAdmin.cshtml index 9e7f9e475..9993d13cc 100644 --- a/src/Moonglade.Web/Pages/Shared/_LayoutAdmin.cshtml +++ b/src/Moonglade.Web/Pages/Shared/_LayoutAdmin.cshtml @@ -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(); - var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorScheme:HeaderName"]!]; + var prefersColorScheme = Context.Request.Headers[Configuration["PrefersColorSchemeHeader:HeaderName"]!]; if (usePrefersColorSchemeHeader && prefersColorScheme == "dark") { useServerSideDarkMode = true;