欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Blazor 中的 PageTitle 输出关键字和描述,自定义组件

最编程 2024-05-07 13:24:28
...
1 @* <PageTitle>@Title - @AppTitle</PageTitle> *@ 2 <HeadContent> 3 @(new MarkupString($"<meta name=\"keywords\" content=\"{Keywords}\" />")) 4 @(new MarkupString($"<meta name=\"description\" content=\"{Description}\" />")) 5 <title>@(new MarkupString($"{Title} - {AppTitle}"))</title> 6 </HeadContent> 7 8 @code { 9 /// <summary> 10 /// 默认的标题后缀 11 /// </summary> 12 [Parameter] 13 public string AppTitle { get; set; } = "宅猫君资源"; 14 /// <summary> 15 /// 默认的爬虫抓取搜索关键词 16 /// </summary> 17 public const string DefaultKeyWords = "宅猫君游戏,宅猫君模型,宅猫君在线资源,宅猫君手游"; 18 /// <summary> 19 /// 获取或设置当前的标题 20 /// </summary> 21 [Parameter] 22 public string Title { get; set; } = "主页"; 23 /// <summary> 24 /// 获取或设置当前的标题 25 /// </summary> 26 [Parameter] 27 public string Keywords { get; set; } = DefaultKeyWords; 28 /// <summary> 29 /// 获取或设置当前的标题 30 /// </summary> 31 [Parameter] 32 public string Description { get; set; } = DefaultKeyWords; 33 }