Skip to content

Commit 3770401

Browse files
committed
update special page;
1 parent 64bc1cd commit 3770401

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

src/CodeWF/Services/AppService.cs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ public class AppService(IOptions<SiteOption> siteOption)
1212
private List<FriendLinkItem>? _friendLinkItems;
1313
private List<TimeLineItem>? _TimeLineItems;
1414
private Dictionary<string, string>? _webSiteCountInfos;
15-
private string? _donationContent;
16-
private string? _aboutContent;
15+
private string? _donationMarkdown;
16+
private string? _donationHtmlContent;
17+
private string? _aboutMarkdown;
18+
private string? _aboutHtmlContent;
1719
private string? _rss;
1820
private string? _siteMap;
1921

@@ -320,40 +322,40 @@ public async Task<Dictionary<string, string>> GetWebSiteCountAsync()
320322
return _webSiteCountInfos;
321323
}
322324

323-
public async Task<string?> ReadAboutAsync()
325+
public async Task<(string? Markdown, string? HtmlContent)> ReadAboutAsync()
324326
{
325-
if (!string.IsNullOrWhiteSpace(_aboutContent))
327+
if (!string.IsNullOrWhiteSpace(_aboutMarkdown))
326328
{
327-
return _aboutContent;
329+
return (_aboutMarkdown, _aboutHtmlContent);
328330
}
329331

330332
var filePath = Path.Combine(siteOption.Value.LocalAssetsDir, "site", "about.md");
331333
if (!File.Exists(filePath))
332334
{
333-
return "## 关于";
335+
return ("## 关于", "关于");
334336
}
335337

336-
var content = await File.ReadAllTextAsync(filePath);
337-
_aboutContent = content.ToHtml();
338-
return _aboutContent;
338+
_aboutMarkdown = await File.ReadAllTextAsync(filePath);
339+
_aboutHtmlContent = _aboutMarkdown.ToHtml();
340+
return (_aboutMarkdown, _aboutHtmlContent);
339341
}
340342

341-
public async Task<string?> ReadDonationAsync()
343+
public async Task<(string? Markdown, string? HtmlContent)> ReadDonationAsync()
342344
{
343-
if (!string.IsNullOrWhiteSpace(_donationContent))
345+
if (!string.IsNullOrWhiteSpace(_donationMarkdown))
344346
{
345-
return _donationContent;
347+
return (_donationMarkdown, _donationHtmlContent);
346348
}
347349

348350
var filePath = Path.Combine(siteOption.Value.LocalAssetsDir, "site", "pays", "Donation.md");
349351
if (!File.Exists(filePath))
350352
{
351-
return "## 赞助";
353+
return ("## 赞助", "赞助");
352354
}
353355

354-
var content = await File.ReadAllTextAsync(filePath);
355-
_donationContent = content.ToHtml();
356-
return _donationContent;
356+
_donationMarkdown = await File.ReadAllTextAsync(filePath);
357+
_donationHtmlContent = _donationMarkdown.ToHtml();
358+
return (_donationMarkdown, _donationHtmlContent);
357359
}
358360

359361
public async Task<BlogPost?> GetPostBySlug(string slug)

src/WebSite/Pages/About.razor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
@inherits BaseComponent
44
@inject AppService AppService
55

6-
<CommonMarkdown Title="关于" Content="@_html"/>
6+
<CommonMarkdown Title="关于" Markdown="@_markdown" HtmlContent="@_html" />
77

88
@code
99
{
10+
private string? _markdown;
1011
private string? _html;
1112

1213
protected override async Task OnInitAsync()
1314
{
1415
await base.OnInitAsync();
15-
_html = await AppService.ReadAboutAsync();
16+
(_markdown, _html) = await AppService.ReadAboutAsync();
1617
}
1718
}

src/WebSite/Pages/Donation.razor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
@inherits BaseComponent
44
@inject AppService AppService
55

6-
<CommonMarkdown Title="赞助" Content="@_html"/>
6+
<CommonMarkdown Title="赞助" Markdown="@_markdown" HtmlContent="@_html" />
77

88
@code
99
{
10+
private string? _markdown;
1011
private string? _html;
1112

1213
protected override async Task OnInitAsync()
1314
{
1415
await base.OnInitAsync();
15-
_html = await AppService.ReadDonationAsync();
16+
(_markdown, _html) = await AppService.ReadDonationAsync();
1617
}
1718
}

src/WebSite/Shared/CommonMarkdown.razor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</HeadTemplate>
1212
<ChildContent>
1313
<div class="title">@Title</div>
14-
<UPostInfo Title="@Title" Content="@Content" />
14+
<UPostInfo Title="@Title" Markdown="@Markdown" Content="@HtmlContent" />
1515
</ChildContent>
1616
</CmsCard>
1717
<div style="height:20px;"></div>
@@ -26,5 +26,6 @@
2626
@code
2727
{
2828
[Parameter] public string Title { get; set; }
29-
[Parameter] public string Content { get; set; }
29+
[Parameter] public string Markdown { get; set; }
30+
[Parameter] public string HtmlContent { get; set; }
3031
}

0 commit comments

Comments
 (0)