From 22b774d29240368b54e92cebbd784be3bf013669 Mon Sep 17 00:00:00 2001 From: wayne Date: Sat, 12 Oct 2024 20:33:06 +0800 Subject: [PATCH] Check meta keyword description is empty --- .../Views/Shared/Partial.PageHeader.cshtml | 10 ++++++++-- src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml | 5 ++++- .../Views/Shared/_CustomerCenterLayout.cshtml | 5 ++++- src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml | 5 ++++- src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml | 5 ++++- src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml | 5 ++++- .../Views/Shared/_PopUpClientLayout.cshtml | 5 ++++- src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml | 5 ++++- src/ZKEACMS/Page/IPageContext.cs | 2 +- src/ZKEACMS/Page/PageContext.cs | 4 ++-- 10 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml b/src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml index 665637d8..2de2fa29 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml @@ -12,8 +12,14 @@ var favicon = applicationSettingService.Get(SettingKeys.Favicon, "~/favicon.ico"); } @currentPage.Title - - +@if (currentPage.MetaKeyWords.IsNotNullAndWhiteSpace()) +{ + +} +@if (currentPage.MetaDescription.IsNotNullAndWhiteSpace()) +{ + +} diff --git a/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml index 0824343d..939b026d 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml @@ -8,7 +8,10 @@ Style.Reqiured("admin").AtHead(); Script.Reqiured("admin").AtHead(); List menus = adminMenuProvider.GetAdminMenus().ToList(); - this.WorkContext().CurrentPage.Title = ZKEACMS.Version.CurrentVersion + " " + ZKEACMS.Version.Rank; + if (this.WorkContext().CurrentPage.Title.IsNullOrEmpty()) + { + this.WorkContext().CurrentPage.Title = ZKEACMS.Version.CurrentVersion + " " + ZKEACMS.Version.Rank; + } } @inject IOptions cultureOption diff --git a/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml index 4e6892b2..5ff8efae 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml @@ -6,7 +6,10 @@ Style.Reqiured("Customer").AtHead(); Style.Reqiured("Easy").AtHead(); IEnumerable menu = userCenterLinkService.GetLinks(); - this.WorkContext().CurrentPage.Title = ViewBag.Title; + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } @inject IUserCenterLinkService userCenterLinkService @inject IOptions cultureOption diff --git a/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml index 07d9337d..22b0fa8e 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml @@ -1,7 +1,10 @@ @using Microsoft.AspNetCore.Hosting @using Microsoft.Extensions.Hosting @{ - this.WorkContext().CurrentPage.Title = ViewBag.Title; + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } diff --git a/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml index de5d49f0..84e045f0 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml @@ -3,7 +3,10 @@ @using Microsoft.Extensions.Options @using Easy.Options @{ - this.WorkContext().CurrentPage.Title = ViewBag.Title; + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } @inject IOptions cultureOption diff --git a/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml index b8e1f417..a9081ca5 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml @@ -3,7 +3,10 @@ @using Microsoft.Extensions.Options @using Easy.Options @{ - this.WorkContext().CurrentPage.Title = ViewBag.Title; + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } @inject IOptions cultureOption diff --git a/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml index 9710e791..a07deb41 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml @@ -1,7 +1,10 @@ @using Microsoft.AspNetCore.Hosting @using Microsoft.Extensions.Hosting @{ - this.WorkContext().CurrentPage.Title = ViewBag.Title; + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } diff --git a/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml index 45fd8630..1c6b50e5 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml @@ -3,7 +3,10 @@ Script.Reqiured("admin").AtHead(); Style.Reqiured("bootStrap").AtHead(); Style.Reqiured("admin").AtHead(); - this.WorkContext().CurrentPage.Title = ViewBag.Title; + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } diff --git a/src/ZKEACMS/Page/IPageContext.cs b/src/ZKEACMS/Page/IPageContext.cs index 88a8cfe1..a63c56a7 100644 --- a/src/ZKEACMS/Page/IPageContext.cs +++ b/src/ZKEACMS/Page/IPageContext.cs @@ -15,7 +15,7 @@ namespace ZKEACMS.Page public interface IPageContext { string Title { get; set; } - string MetaKeyWorlds { get; set; } + string MetaKeyWords { get; set; } string MetaDescription { get; set; } string CultureCode { get; set; } List Meta { get; } diff --git a/src/ZKEACMS/Page/PageContext.cs b/src/ZKEACMS/Page/PageContext.cs index 6f16bedf..b873248d 100644 --- a/src/ZKEACMS/Page/PageContext.cs +++ b/src/ZKEACMS/Page/PageContext.cs @@ -31,7 +31,7 @@ public class PageContext : IPageContext public List BodyFooter { get; } = new List(); public List StyleNames { get; }= new List(); public List ScriptNames { get; } = new List(); - public string MetaKeyWorlds { get; set; } + public string MetaKeyWords { get; set; } public string MetaDescription { get; set; } public void ConfigSEO(string title, string keywords, string description) @@ -42,7 +42,7 @@ public void ConfigSEO(string title, string keywords, string description) } if (keywords.IsNotNullAndWhiteSpace()) { - MetaKeyWorlds = keywords; + MetaKeyWords = keywords; } if (description.IsNotNullAndWhiteSpace()) {