Skip to content

Instantly share code, notes, and snippets.

@hartez
Created October 19, 2024 20:34
Show Gist options
  • Save hartez/beb6003e71299dab85eed65c16de1b25 to your computer and use it in GitHub Desktop.
Save hartez/beb6003e71299dab85eed65c16de1b25 to your computer and use it in GitHub Desktop.
Custom analyzer for Statiq to validate that my posts have a Description property
using Markdig.Syntax;
using Microsoft.Extensions.Logging;
using Statiq.Common;
namespace EZHart
{
public class PostsShouldHaveDescriptions : SyncMarkdownAnalyzer
{
protected override void Analyze(MarkdownDocument markdown, IDocument document, IAnalyzerContext context)
{
var description = document.GetString(WebKeys.Description);
if(string.IsNullOrEmpty(description))
{
context.AddAnalyzerResult(document, $"{document.Source}: posts should have descriptions.");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment