Skip to content

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented Mar 19, 2025

Details

You can now add the description field to the FrontMatter block on every document.
If the field is not present, then it will be autogenerated based on the content.

@Copilot Copilot AI review requested due to automatic review settings March 19, 2025 16:03
@reakaleek reakaleek requested a review from a team as a code owner March 19, 2025 16:03
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 the ability to set a description meta tag by introducing a new description generator, updating front matter parsing, and propagating the description through various views and templates.

  • Introduces a DescriptionGenerator class to create meta descriptions from Markdown.
  • Updates front matter parsing and ViewModel definitions to include a description.
  • Integrates the new description into the HTML output and adds a dependency in HtmlWriter.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Elastic.Markdown/Slices/DescriptionGenerator.cs New utility to generate a description for meta tags from Markdown.
src/Elastic.Markdown/Myst/FrontMatter/FrontMatterParser.cs Adds a new YAML field for description parsing.
src/Elastic.Markdown/Slices/_ViewModels.cs Updates view models to include the Description property.
src/Elastic.Markdown/Slices/HtmlWriter.cs Uses the new description generator to set the meta description.
src/Elastic.Markdown/Assets/main.ts Imports additional HTMX extension for head support.
src/Elastic.Markdown/DocumentationGenerator.cs Passes the new DescriptionGenerator to HtmlWriter.
src/Elastic.Markdown/Slices/Index.cshtml Updates the layout view to output the description.
src/Elastic.Markdown/Slices/Layout/_Head.cshtml Updates the head markup to include the description meta tag.
Comments suppressed due to low confidence (1)

src/Elastic.Markdown/Slices/DescriptionGenerator.cs:80

  • Add a check to ensure that 'paragraphText' is not empty before accessing its last character to avoid a potential IndexOutOfRangeException in list item processing.
var lastChar = paragraphText[^1];

}

#pragma warning disable IDE0060
private static void ProcessIncludeBlock(IncludeBlock include, StringBuilder description) => Console.WriteLine("Not implemented: ProcessIncludeBlock");
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
private static void ProcessIncludeBlock(IncludeBlock include, StringBuilder description) => Console.WriteLine("Not implemented: ProcessIncludeBlock");
private static void ProcessIncludeBlock(IncludeBlock include, StringBuilder description) {}

Or use our logging infrastructure.

Copy link
Member

Choose a reason for hiding this comment

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

You could use discard parameters to not have the #pragma

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. Interestingly, I had an error saying something like Duplicate arg "_" something something.

But I'm going to clean this up and just add a comment instead.

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 20:59
@reakaleek reakaleek self-assigned this Mar 19, 2025
# Conflicts:
#	src/Elastic.Markdown/Slices/HtmlWriter.cs
#	src/Elastic.Markdown/Slices/_ViewModels.cs
@reakaleek reakaleek enabled auto-merge (squash) March 19, 2025 22:03
@reakaleek reakaleek disabled auto-merge March 19, 2025 22:03
@reakaleek reakaleek enabled auto-merge (squash) March 19, 2025 22:07
@reakaleek reakaleek merged commit 9c9a40f into main Mar 19, 2025
10 checks passed
@reakaleek reakaleek deleted the feature/meta-description-tag branch March 19, 2025 22:09
@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