!2798 doc(#I58FDJ): add link config file

* feat: 增加友链配置逻辑
* doc: 增加 links.json 友链配置文件
This commit is contained in:
Argo 2022-05-20 04:34:27 +00:00
parent e6c0a602c6
commit d11023aeb6
6 changed files with 50 additions and 34 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Import Project="..\Framework.props" />
@ -10,7 +10,9 @@
<Content Remove="Locales\*.json" />
<EmbeddedResource Include="Locales\*.json" />
<Content Remove="docs.json" />
<Content Remove="links.json" />
<EmbeddedResource Include="docs.json" />
<EmbeddedResource Include="links.json" />
</ItemGroup>
<ItemGroup>

View File

@ -1,4 +1,4 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
@ -110,17 +110,42 @@ public class WebsiteOptions
/// </summary>
public bool IsDevelopment { get; set; }
/// <summary>
/// 获得/设置 当前网站友联集合
/// </summary>
[NotNull]
public Dictionary<string, string>? Links { get; set; }
/// <summary>
/// 构造函数
/// </summary>
public WebsiteOptions()
{
using var res = GetType().Assembly.GetManifestResourceStream($"{GetType().Assembly.GetName().Name}.docs.json");
var config = GetConfiguration("docs.json");
SourceCodes = config.GetSection("src").GetChildren().SelectMany(c => new KeyValuePair<string, string>[]
{
new(c.Key, c.Value)
}).ToDictionary(item => item.Key, item => item.Value);
Videos = config.GetSection("video").GetChildren().SelectMany(c => new KeyValuePair<string, string>[]
{
new(c.Key, c.Value)
}).ToDictionary(item => item.Key, item => item.Value);
var config = new ConfigurationBuilder()
config = GetConfiguration("links.json");
Links = config.GetChildren().SelectMany(c => new KeyValuePair<string, string>[]
{
new (c.Key, c.Value)
}).ToDictionary(item => item.Key, item => item.Value);
}
private IConfiguration GetConfiguration(string jsonFileName)
{
var assembly = GetType().Assembly;
var assemlbyName = assembly.GetName().Name;
using var res = assembly.GetManifestResourceStream($"{assemlbyName}.{jsonFileName}");
return new ConfigurationBuilder()
.AddJsonStream(res)
.Build();
SourceCodes = config.GetSection("src").GetChildren().SelectMany(c => new KeyValuePair<string, string>[] { new KeyValuePair<string, string>(c.Key, c.Value) }).ToDictionary(item => item.Key, item => item.Value);
Videos = config.GetSection("video").GetChildren().SelectMany(c => new KeyValuePair<string, string>[] { new KeyValuePair<string, string>(c.Key, c.Value) }).ToDictionary(item => item.Key, item => item.Value);
}
}

View File

@ -49,8 +49,6 @@
"FooterH1": "Related Works",
"FooterLi1": "Slider verification code",
"FriendLink": "Links",
"FriendLi1": "Lin Dexi's Blog",
"FriendLi2": "CCFlow",
"Community": "Community",
"CommunityLi1": "Contribution guide",
"CommunityLi2": "Join us",

View File

@ -49,8 +49,6 @@
"FooterH1": "相关作品",
"FooterLi1": "滑块验证码",
"FriendLink": "友情链接",
"FriendLi1": "林德熙的博客",
"FriendLi2": "驰骋工作流",
"Community": "社区",
"CommunityLi1": "贡献指南",
"CommunityLi2": "加入我们",

View File

@ -30,30 +30,12 @@
<div>
<h4>@Localizer["FriendLink"]</h4>
<ul>
<li>
<a class="footer-link" href="https://blog.lindexi.com" target="_blank">@Localizer["FriendLi1"]</a>
</li>
<li>
<a class="footer-link" href="https://gitee.com/dotnetchina/Furion" target="_blank">Furion</a>
</li>
<li>
<a class="footer-link" href="http://ccflow.org/?from=blazor" target="_blank">@Localizer["FriendLi2"]</a>
</li>
<li>
<a class="footer-link" href="https://gitee.com/loogn/bulmarazor" target="_blank">Bulma</a>
</li>
<li>
<a class="footer-link" href="http://www.pearadmin.com" target="_blank">Pear Admin</a>
</li>
<li>
<a class="footer-link" href="https://ant-design-blazor.github.io/" target="_blank">Ant design of blazor</a>
</li>
<li>
<a class="footer-link" href="https://dotnet9.com/" target="_blank">Dotnet9</a>
</li>
<li>
<a class="footer-link" href="http://www.mrhuo.com/" target="_blank">M&J</a>
</li>
@foreach (var link in WebsiteOption.CurrentValue.Links)
{
<li>
<a class="footer-link" href="@link.Value" target="_blank">@link.Key</a>
</li>
}
</ul>
</div>
<div>

View File

@ -0,0 +1,11 @@
{
"Lin Dexi's Blog": "https://blog.lindexi.com",
"Furion": "https://gitee.com/dotnetchina/Furion",
"CCFlow": "http://ccflow.org/?from=blazor",
"Bulma": "https://gitee.com/loogn/bulmarazor",
"Pear Admin": "http://www.pearadmin.com",
"Ant design of blazor": "https://ant-design-blazor.github.io/",
"Dotnet9": "https://dotnet9.com/",
"M&J": "http://www.mrhuo.com/",
"SAPHP": "https://www.swiftadmin.net/"
}