Created
October 19, 2024 20:34
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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