Skip to content

Commit

Permalink
[doc] navigation matching fine-tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
hakenr committed Dec 12, 2024
1 parent cfc9744 commit 2f32b33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,27 @@ private static bool IsStrictlyPrefixWithSeparator(string value, string prefix)
// Example: "/abc" is treated as a prefix of "/abc/def" but not "/abcdef"
// Example: "/abc/" is treated as a prefix of "/abc/def" but not "/abcdef"
prefixLength == 0
|| !char.IsLetterOrDigit(prefix[prefixLength - 1])
|| !char.IsLetterOrDigit(value[prefixLength])
|| !IsUnreservedCharacter(prefix[prefixLength - 1])
|| !IsUnreservedCharacter(value[prefixLength])
);
}
else
{
return false;
}
}

private static bool IsUnreservedCharacter(char c)
{
// Checks whether it is an unreserved character according to
// https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
// Those are characters that are allowed in a URI but do not have a reserved
// purpose (e.g. they do not separate the components of the URI)
return char.IsLetterOrDigit(c) ||
c == '-' ||
c == '.' ||
c == '_' ||
c == '~';
}
#endregion
}
10 changes: 5 additions & 5 deletions Havit.Blazor.Documentation/Shared/Navbar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
<HxNavbarToggler CssClass="border-0" />
<HxNavbarCollapse>
<HxNav CssClass="mx-auto justify-content-center gap-3 my-3 my-lg-0">
<HxNavLink Href="/" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover" Match="NavLinkMatch.All">
<HxNavLink Href="" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover" Match="NavLinkMatch.All">
Introduction
</HxNavLink>
<HxNavLink Href="/getting-started" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover" Match="NavLinkMatch.All">
<HxNavLink Href="getting-started" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover">
Documentation
</HxNavLink>
<HxNavLink Href="https://blocks.havit.blazor.eu" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover" Match="NavLinkMatch.All">
<HxNavLink Href="https://blocks.havit.blazor.eu" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover">
Blocks
</HxNavLink>
<HxNavLink Href="/showcase" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover" Match="NavLinkMatch.Prefix">
<HxNavLink Href="showcase" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover">
Showcase
</HxNavLink>
<HxNavLink Href="/premium" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover" Match="NavLinkMatch.All">
<HxNavLink Href="premium" CssClass="px-3 link-body-emphasis link-opacity-75 link-opacity-100-hover">
Premium
</HxNavLink>
</HxNav>
Expand Down
4 changes: 2 additions & 2 deletions Havit.Blazor.Documentation/Shared/Sidebar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</div>
</HeaderTemplate>
<ItemsTemplate>
<HxSidebarItem Text="Getting started" Href="/getting-started" Match="NavLinkMatch.All" Icon="BootstrapIcon.RocketTakeoff" TooltipText="Getting started" />
<HxSidebarItem Href="https://blocks.havit.blazor.eu" Match="NavLinkMatch.All" CssClass="w-100" Icon="BootstrapIcon.Boxes" TooltipText="Blocks" >
<HxSidebarItem Text="Getting started" Href="getting-started" Icon="BootstrapIcon.RocketTakeoff" TooltipText="Getting started" />
<HxSidebarItem Href="https://blocks.havit.blazor.eu" CssClass="w-100" Icon="BootstrapIcon.Boxes" TooltipText="Blocks" >
<ContentTemplate>
<div class="flex-grow-1">Blocks 🔥</div>
<HxBadge CssClass="ms-auto fw-normal rounded-pill" style="background-image: linear-gradient(to right, transparent, rgba(17, 71, 136))" Color="ThemeColor.Primary">Premium</HxBadge>
Expand Down

0 comments on commit 2f32b33

Please sign in to comment.