Browse Source

SEO规范

懒得勤快 5 years ago
parent
commit
aa742dec3b

+ 1 - 1
src/Masuit.MyBlogs.Core/Controllers/ErrorController.cs

@@ -92,7 +92,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         });
                     case AccessDenyException _:
                         var (location, network) = IPAddress.Parse(ip).GetIPLocation();
-                        var tips = new Template(CommonHelper.SystemSettings.GetOrAdd("AccessDenyTips", @"<h4>遇到了什么问题?</h4>
+                        var tips = Template.Create(CommonHelper.SystemSettings.GetOrAdd("AccessDenyTips", @"<h4>遇到了什么问题?</h4>
                 <h4>基于主观因素考虑,您所在的地区暂时不允许访问本站,如有疑问,请联系站长!或者请联系站长开通本站的访问权限!</h4>")).Set("clientip", ip).Set(nameof(location), location).Set(nameof(network), network).Render();
                         Response.StatusCode = 403;
                         return View("AccessDeny", tips);

+ 15 - 5
src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs

@@ -3,6 +3,7 @@ using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Caching.Memory;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -50,7 +51,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// RSS订阅
         /// </summary>
         /// <returns></returns>
-        [Route("/rss"), ResponseCache(Duration = 600)]
+        [Route("/rss"), ResponseCache(Duration = 3600)]
         public IActionResult Rss()
         {
             var time = DateTime.Today.AddDays(-1);
@@ -74,7 +75,10 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
                 FullHtmlContent = p.Content.GetSummary(300, 50)
-            }).FromCache().ToList();
+            }).FromCache(new MemoryCacheEntryOptions()
+            {
+                AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
+            }).ToList();
             var feed = new Feed()
             {
                 Title = CommonHelper.SystemSettings["Title"],
@@ -95,7 +99,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// RSS分类订阅
         /// </summary>
         /// <returns></returns>
-        [Route("/cat/{id}/rss"), ResponseCache(Duration = 600)]
+        [Route("/cat/{id}/rss"), ResponseCache(Duration = 3600)]
         public IActionResult CategoryRss(int id)
         {
             var time = DateTime.Today.AddDays(-1);
@@ -120,7 +124,10 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
                 FullHtmlContent = p.Content.GetSummary(300, 50)
-            }).FromCache().ToList();
+            }).FromCache(new MemoryCacheEntryOptions()
+            {
+                AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
+            }).ToList();
             var feed = new Feed()
             {
                 Title = Request.Host + $":分类{category.Name}文章订阅",
@@ -141,7 +148,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// RSS文章订阅
         /// </summary>
         /// <returns></returns>
-        [Route("/{id}/rss"), ResponseCache(Duration = 600)]
+        [Route("/{id}/rss"), ResponseCache(Duration = 3600)]
         public IActionResult PostRss(int id)
         {
             string scheme = Request.Scheme;
@@ -211,6 +218,9 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Permalink = $"{scheme}://{host}/{post.Id}?cid={c.Id}#comment",
                 Guid = c.Id.ToString(),
                 FullHtmlContent = c.Content
+            }).FromCache(new MemoryCacheEntryOptions()
+            {
+                AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10)
             }).ToList();
             var feed = new Feed()
             {

+ 2 - 2
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -44,10 +44,10 @@
         <PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.2.1" />
         <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
         <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
-        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.7" />
+        <PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.8" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.6.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
-        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.53" />
+        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.54" />
     </ItemGroup>
     <ItemGroup>
         <Content Update="appsettings.json">

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/Details.cshtml

@@ -43,9 +43,9 @@
                         <header class="page-header">
                             <div class="text-center">
                                 <a>
-                                    <h1 class="padding-bot10">
+                                    <h2 class="padding-bot10">
                                         @Model.Title
-                                    </h1>
+                                    </h2>
                                 </a>
                             </div>
                             <div class="row">

+ 2 - 2
src/Masuit.MyBlogs.Core/Views/Post/Details_Admin.cshtml

@@ -44,9 +44,9 @@
                         <header class="page-header">
                             <div class="text-center">
                                 <a>
-                                    <h1 class="padding-bot10">
+                                    <h2 class="padding-bot10">
                                         @Model.Title
-                                    </h1>
+                                    </h2>
                                 </a>
                             </div>
                             <div class="row">

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Shared/_Layout.cshtml

@@ -83,7 +83,7 @@
     </div>
     <div class="header">
         <header class="cd-main-header">
-            <a class="cd-logo" href="/"><img src="@CommonHelper.SystemSettings["logo"]" alt="@CommonHelper.SystemSettings["Title"]"><span class="slogan">@CommonHelper.SystemSettings["Slogan"]</span></a>
+            <a class="cd-logo" href="/"><img src="@CommonHelper.SystemSettings["logo"]" alt="@CommonHelper.SystemSettings["Title"]"><h1 class="slogan">@CommonHelper.SystemSettings["Slogan"]</h1></a>
             <ul class="cd-header-buttons">
                 <li><a class="cd-search-trigger" href="#cd-search">搜索<span></span></a></li>
                 <li><a class="cd-nav-trigger" href="#cd-primary-nav">菜单<span></span></a></li>

+ 1 - 1
src/Masuit.MyBlogs.Core/wwwroot/Content/common/articlestyle.css

@@ -315,7 +315,7 @@ article table > tbody > tr.danger:hover > th { background-color: #ebcccc; }
 
 .ibox-content div.col-md-3 { text-align: center; }
 
-.article > .ibox > .ibox-content > main header.page-header a h1 {
+.article > .ibox > .ibox-content > main header.page-header a h2 {
     font-size: 24px;
     line-height: 32px;
 }