Skip to content

Conversation

reakaleek
Copy link
Member

No description provided.

@Copilot Copilot AI review requested due to automatic review settings March 19, 2025 12:30
@reakaleek reakaleek requested a review from a team as a code owner March 19, 2025 12:30
@reakaleek reakaleek self-assigned this Mar 19, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for specifying a canonical base URL throughout the documentation site. Key changes include:

  • Introducing a new nullable property CanonicalBaseUrl in BuildContext and updating related view models.
  • Adding a new CLI parameter for canonicalBaseUrl and wiring it through the documentation generation process.
  • Incorporating the canonical URL tag in the rendered HTML head section.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Elastic.Markdown/BuildContext.cs Adds a new property to hold the canonical base URL
src/Elastic.Markdown/Slices/_ViewModels.cs Updates view models to include the canonical base URL property
src/docs-builder/Cli/Commands.cs Introduces the canonicalBaseUrl CLI parameter and propagates it
src/Elastic.Markdown/Slices/HtmlWriter.cs Incorporates trimming for the canonical base URL before usage
src/Elastic.Markdown/Slices/Index.cshtml Passes canonicalBaseUrl to the view
src/Elastic.Markdown/Slices/Layout/_Head.cshtml Renders the canonical link tag based on the canonical base URL
Comments suppressed due to low confidence (1)

src/Elastic.Markdown/Slices/Layout/_Head.cshtml:13

  • Consider using a URL join method or ensuring proper slash handling when concatenating Model.CanonicalBaseUrl and Model.CurrentDocument.Url to avoid malformed canonical URLs.
<link rel="canonical" href="@(Model.CanonicalBaseUrl + Model.CurrentDocument.Url)">

public bool AllowIndexing { get; init; }

// This property is used for the canonical URL
public string? CanonicalBaseUrl { get; init; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uri instead of string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@if (Model.CanonicalBaseUrl is not null)
{
<link rel="canonical" href="@(Model.CanonicalBaseUrl + Model.CurrentDocument.Url)">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<link rel="canonical" href="@(Model.CanonicalBaseUrl + Model.CurrentDocument.Url)">
<link rel="canonical" href="@(new Uri(Model.CanonicalBaseUri, Model.CurrentDocument.Url))">

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force = force ?? false,
AllowIndexing = allowIndexing ?? false
AllowIndexing = allowIndexing ?? false,
CanonicalBaseUrl = canonicalBaseUrl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uri.TryCreate(...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reakaleek reakaleek requested a review from Mpdreamz March 19, 2025 21:15
@reakaleek reakaleek merged commit 30b2678 into main Mar 19, 2025
10 checks passed
@reakaleek reakaleek deleted the feature/add-canonical-tag branch March 19, 2025 22:02
@reakaleek reakaleek added the SEO label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants