fix: tags in essay card and essay page.
All checks were successful
Build blog docker image / Build-Blog-Image (push) Successful in 2m30s

This commit is contained in:
jackfiled 2024-08-14 00:01:12 +08:00
parent 759ffadd2e
commit fe0a804677
3 changed files with 12 additions and 17 deletions

View File

@ -216,29 +216,20 @@ public partial class RendererService(
private uint GetWordCount(BlogContent content)
{
uint count = 0;
foreach (char c in content.FileContent)
{
if (char.IsControl(c) || char.IsSymbol(c)
|| char.IsSeparator(c))
{
continue;
}
count++;
}
int count = (from c in content.FileContent
where char.IsLetterOrDigit(c)
select c).Count();
logger.LogDebug("Word count of {} is {}", content.FileName,
count);
return count;
return (uint)count;
}
private static string CalculateReadTime(uint wordCount)
{
// 据说语文教学大纲规定,中国高中阅读现代文的速度是600字每分钟
// 据说语文教学大纲规定中国高中生阅读现代文的速度是600字每分钟
int second = (int)wordCount / 10;
TimeSpan span = new TimeSpan(0, 0, second);
TimeSpan span = new(0, 0, second);
return span.ToString("mm'分 'ss'秒'");
}

View File

@ -1,3 +1,4 @@
@using System.Text.Encodings.Web
@using YaeBlog.Core.Models
<div class="container p-3">
@ -13,7 +14,7 @@
@foreach (string key in Essay.Tags)
{
<div class="col-auto">
<a href="/blog/tags/?tagName=@key">
<a href="/blog/tags/?tagName=@(UrlEncoder.Default.Encode(key))">
# @key
</a>
</div>

View File

@ -1,4 +1,5 @@
@page "/blog/essays/{BlogKey}"
@using System.Text.Encodings.Web
@using YaeBlog.Core.Abstractions
@using YaeBlog.Core.Models
@ -25,7 +26,9 @@
@foreach (string tag in _essay!.Tags)
{
<div class="col-auto">
<a href="/tags/?tagName=@(tag)"># @(tag)</a>
<a href="/blog/tags/?tagName=@(UrlEncoder.Default.Encode(tag))">
# @(tag)
</a>
</div>
}
</div>