Skip to content

Commit

Permalink
Check meta keyword description is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriaWei committed Oct 12, 2024
1 parent 35401e8 commit 22b774d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 12 deletions.
10 changes: 8 additions & 2 deletions src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
var favicon = applicationSettingService.Get(SettingKeys.Favicon, "~/favicon.ico");
}
<title>@currentPage.Title</title>
<meta name="keywords" content="@currentPage.MetaKeyWorlds" />
<meta name="description" content="@currentPage.MetaDescription" />
@if (currentPage.MetaKeyWords.IsNotNullAndWhiteSpace())
{
<meta name="keywords" content="@currentPage.MetaKeyWords" />
}
@if (currentPage.MetaDescription.IsNotNullAndWhiteSpace())
{
<meta name="description" content="@currentPage.MetaDescription" />
}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<meta name="author" content="ZKEASOFT" />
Expand Down
5 changes: 4 additions & 1 deletion src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
Style.Reqiured("admin").AtHead();
Script.Reqiured("admin").AtHead();
List<AdminMenu> 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> cultureOption
<!DOCTYPE html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
Style.Reqiured("Customer").AtHead();
Style.Reqiured("Easy").AtHead();
IEnumerable<AdminMenu> 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> cultureOption
Expand Down
5 changes: 4 additions & 1 deletion src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml
Original file line number Diff line number Diff line change
@@ -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;
}
}
<!DOCTYPE html>
<html>
Expand Down
5 changes: 4 additions & 1 deletion src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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> cultureOption
<!DOCTYPE html>
Expand Down
5 changes: 4 additions & 1 deletion src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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> cultureOption
<!DOCTYPE html>
Expand Down
5 changes: 4 additions & 1 deletion src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml
Original file line number Diff line number Diff line change
@@ -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;
}
}
<!DOCTYPE html>
<html style="height:100%">
Expand Down
5 changes: 4 additions & 1 deletion src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS/Page/IPageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MetaTag> Meta { get; }
Expand Down
4 changes: 2 additions & 2 deletions src/ZKEACMS/Page/PageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PageContext : IPageContext
public List<IHtmlContent> BodyFooter { get; } = new List<IHtmlContent>();
public List<string> StyleNames { get; }= new List<string>();
public List<string> ScriptNames { get; } = new List<string>();
public string MetaKeyWorlds { get; set; }
public string MetaKeyWords { get; set; }
public string MetaDescription { get; set; }

public void ConfigSEO(string title, string keywords, string description)
Expand All @@ -42,7 +42,7 @@ public void ConfigSEO(string title, string keywords, string description)
}
if (keywords.IsNotNullAndWhiteSpace())
{
MetaKeyWorlds = keywords;
MetaKeyWords = keywords;
}
if (description.IsNotNullAndWhiteSpace())
{
Expand Down

0 comments on commit 22b774d

Please sign in to comment.