-
Notifications
You must be signed in to change notification settings - Fork 30
Add ability to set description meta tag #778
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
Conversation
There was a problem hiding this 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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Conflicts: # src/Elastic.Markdown/Slices/HtmlWriter.cs # src/Elastic.Markdown/Slices/_ViewModels.cs
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.