Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/HtmlTag/Link.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase

<link @attributes="AdditionalAttributes" href="@GetHref()" rel="stylesheet" />
<link @attributes="AdditionalAttributes" href="@GetHref()" rel="@Rel" />
6 changes: 6 additions & 0 deletions src/BootstrapBlazor/Components/HtmlTag/Link.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public partial class Link
[EditorRequired]
public string? Href { get; set; }

/// <summary>
/// 获得/设置 Rel 属性值, 默认 stylesheet
/// </summary>
[Parameter]
public string? Rel { get; set; } = "stylesheet";

/// <summary>
/// 获得/设置 版本号 默认 null 自动生成
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion test/UnitTest/Components/LinkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public void Link_Ok()
var cut = Context.RenderComponent<Link>(pb =>
{
pb.Add(a => a.Href, "http://www.blazor.zone");
pb.Add(a => a.Rel, "stylesheet-test");
});
var versionService = cut.Services.GetRequiredService<IVersionService>();
Assert.Equal($"<link href=\"http://www.blazor.zone?v={versionService.GetVersion()}\" rel=\"stylesheet\" />", cut.Markup);
Assert.Equal($"<link href=\"http://www.blazor.zone?v={versionService.GetVersion()}\" rel=\"stylesheet-test\" />", cut.Markup);
}

[Fact]
Expand Down