Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Canonical URLs metadata #914 #915

Merged
merged 6 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxAccordion))]
@attribute [Route("/components/" + nameof(HxAccordionItem))]

<ComponentApiDoc Type="typeof(HxAccordion)">
<ComponentApiDoc Type="typeof(HxAccordion)" MainComponent>
<DocAlert Type="DocAlertType.Warning">
Avoid using a constant value for <code>@nameof(HxAccordion.ExpandedItemId)</code>,
as it resets the accordion to that specific item on each roundtrip.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxBreadcrumb))]
@attribute [Route("/components/" + nameof(HxBreadcrumbItem))]

<ComponentApiDoc Type="typeof(HxBreadcrumb)">
<ComponentApiDoc Type="typeof(HxBreadcrumb)" MainComponent>
<DocHeading Title="Basic usage" />
<p>Set <code>HxBreadcrumbItem.Active</code> to <code>true</code> to indicate the current page the user is on.</p>
<Demo Type="typeof(HxBreadcrumb_Demo)" Tabs="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxButton))]
@attribute [Route("/components/" + nameof(HxSubmit))]

<ComponentApiDoc Type="typeof(HxButton)">
<ComponentApiDoc Type="typeof(HxButton)" MainComponent>
<MainContent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxButton_Demo_Basic)" Tabs="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxButtonGroup))]
@attribute [Route("/components/" + nameof(HxButtonToolbar))]

<ComponentApiDoc Type="typeof(HxButtonGroup)">
<ComponentApiDoc Type="typeof(HxButtonGroup)" MainComponent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxButtonGroup_Demo)" Tabs="false" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@attribute [Route("/components/" + nameof(HxCardTitle))]
@attribute [Route("/components/" + nameof(HxCardSubtitle))]

<ComponentApiDoc Type="typeof(HxCard)">
<ComponentApiDoc Type="typeof(HxCard)" MainComponent>

<DocHeading Title="About" />
<p>A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@attribute [Route("/components/" + nameof(HxCollapseToggleButton))]
@attribute [Route("/components/" + nameof(HxCollapseToggleElement))]

<ComponentApiDoc Type="typeof(HxCollapse)">
<ComponentApiDoc Type="typeof(HxCollapse)" MainComponent>

<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxCollapse_Demo_Basic)" Tabs="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@attribute [Route("/components/" + nameof(HxContextMenu))]

<ComponentApiDoc Type="typeof(HxContextMenu)">
<ComponentApiDoc Type="typeof(HxContextMenu)" MainComponent>
<MainContent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxContextMenu_Demo)" Tabs="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@using Components.HxNavDoc


<ComponentApiDoc Type="typeof(HxDropdownButtonGroup)">
<ComponentApiDoc Type="typeof(HxDropdownButtonGroup)" MainComponent>

<DocHeading Title="Basic usage" />
<p>Dropdowns are usually used in combination with a button. For such cases, use the <a href="components/HxDropdownButtonGroup"><code>HxDropdownButtonGroup</code></a> and <a href="components/HxDropdownToggleButton"><code>HxDropdownToggleButton</code></a>.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@using Components.HxNavDoc


<ComponentApiDoc Type="typeof(HxDropdown)">
<ComponentApiDoc Type="typeof(HxDropdown)" MainComponent>
<MainContent>
<DocHeading Title="Basic usage" />
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@attribute [Route("/components/" + nameof(HxGoogleTagManagerPageViewTracker))]
@using Havit.Blazor.GoogleTagManager

<ComponentApiDoc Type="typeof(HxGoogleTagManager)">
<ComponentApiDoc Type="typeof(HxGoogleTagManager)" MainComponent>
<DocAlert Type="DocAlertType.Warning">
<code>HxGoogleTagManager</code> and related components are distributed in a separate NuGet package: <a href="https://www.nuget.org/packages/Havit.Blazor.GoogleTagManager">Havit.Blazor.GoogleTagManager</a>.
</DocAlert>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxGrid))]
@attribute [Route("/components/" + nameof(HxGridColumn<object>))]

<ComponentApiDoc Type="typeof(HxGrid<TItem>)">
<ComponentApiDoc Type="typeof(HxGrid<TItem>)" MainComponent>
<MainContent>

<DocHeading Title="Basic usage" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxInputFile))]
@attribute [Route("/components/" + nameof(HxInputFileCore))]

<ComponentApiDoc Type="typeof(HxInputFile)">
<ComponentApiDoc Type="typeof(HxInputFile)" MainComponent>

<DocAlert Type="DocAlertType.Info">
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxListGroup))]

<div>@* CSS isolation support *@
<ComponentApiDoc Type="typeof(HxListGroup)">
<ComponentApiDoc Type="typeof(HxListGroup)" MainComponent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxListGroup_Demo)" Tabs="false" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxMessageBox))]
@attribute [Route("/components/" + nameof(HxMessageBoxHost))]

<ComponentApiDoc Type="typeof(HxMessageBox)">
<ComponentApiDoc Type="typeof(HxMessageBox)" MainComponent>

<DocAlert Type="DocAlertType.Info">
<code>@nameof(HxMessageBox)</code> is an implementation component that you use directly only in rare specific cases.<br />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxNav))]
@attribute [Route("/components/" + nameof(HxNavLink))]

<ComponentApiDoc Type="typeof(HxNav)">
<ComponentApiDoc Type="typeof(HxNav)" MainComponent>
<DocHeading Title="Base Nav" />
<Demo Type="typeof(HxNav_Demo_BaseNav)" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@attribute [Route("/components/" + nameof(HxNavbarCollapse))]
@attribute [Route("/components/" + nameof(HxNavbarText))]

<ComponentApiDoc Type="typeof(HxNavbar)">
<ComponentApiDoc Type="typeof(HxNavbar)" MainComponent>

<DocAlert Type="DocAlertType.Warning">
<strong>UPDATE v4.0.1:</strong> As Bootstrap 5.3 now expects you to use <a href="https://getbootstrap.com/docs/5.3/components/navbar/#color-schemes">text and background color CSS utilities</a> to customize the navbar with the <code>CssClass</code> parameter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@attribute [Route("/components/" + nameof(HxPlaceholderContainer))]
@attribute [Route("/components/" + nameof(HxPlaceholderButton))]

<ComponentApiDoc Type="typeof(HxPlaceholder)">
<ComponentApiDoc Type="typeof(HxPlaceholder)" MainComponent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxPlaceholder_Demo_BasicExample)" Tabs="false" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxProgress))]
@attribute [Route("/components/" + nameof(HxProgressBar))]

<ComponentApiDoc Type="typeof(HxProgress)">
<ComponentApiDoc Type="typeof(HxProgress)" MainComponent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxProgress_Demo)" Tabs="false" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/components/HxScrollspy"

<ComponentApiDoc Type="typeof(HxScrollspy)">
<ComponentApiDoc Type="typeof(HxScrollspy)" MainComponent>

<DocHeading Title="How it works" />
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@attribute [Route("/components/" + nameof(HxSidebarItem))]
@attribute [Route("/components/" + nameof(HxSidebarBrand))]

<ComponentApiDoc Type="typeof(HxSidebar)">
<ComponentApiDoc Type="typeof(HxSidebar)" MainComponent>
<MainContent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxSidebar_Demo)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxTabPanel))]
@attribute [Route("/components/" + nameof(HxTab))]

<ComponentApiDoc Type="typeof(HxTabPanel)">
<ComponentApiDoc Type="typeof(HxTabPanel)" MainComponent>
<DocHeading Title="Basic usage" />
<Demo Type="typeof(HxTabPanel_Demo_BasicUsage)" Tabs="false" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@attribute [Route("/components/" + nameof(HxToast))]
@attribute [Route("/components/" + nameof(HxToastContainer))]

<ComponentApiDoc Type="typeof(HxToast)">
<ComponentApiDoc Type="typeof(HxToast)" MainComponent>
<MainContent>
<DocHeading Title="Basic usage" />
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
@{
var plainTypeName = ApiRenderer.RemoveSpecialCharacters(Type.Name);
}

@if (MainComponent)
{
<HeadContent>
<link rel="canonical" href="@("https://havit.blazor.eu/components/" + plainTypeName)" />
</HeadContent>
}

<DocHeading Title="@plainTypeName" Id="@plainTypeName" Level="1" />
@if (!String.IsNullOrWhiteSpace(_model.Class?.Comments?.Summary))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public partial class ComponentApiDoc
/// </summary>
[Parameter] public Type Type { get; set; }

/// <summary>
/// This is used to determine, whether the <c>rel="canonical"</c> link element should be rendered.
/// Set to true, if the documentation page contains more than one component and this component is representative of the page.
/// </summary>
[Parameter] public bool MainComponent { get; set; } = false;

[Inject] protected IComponentApiDocModelBuilder ComponentApiDocModelBuilder { get; set; }

private ComponentApiDocModel _model;
Expand Down