@@ -2,6 +2,8 @@ import { globSync } from "glob";
22import { readFileSync } from "node:fs" ;
33import { extname , basename } from "node:path" ;
44import { getFrontmatter } from "myst-transforms" ;
5+ import { validatePageFrontmatter } from "myst-frontmatter" ;
6+ import { fileError , fileWarn } from "myst-common" ;
57
68const blogPostsDirective = {
79 name : "blog-posts" ,
@@ -14,10 +16,27 @@ const blogPostsDirective = {
1416 const paths = globSync ( "posts/*.md" ) . sort ( ) . reverse ( ) ; // For now, string sort
1517 const nodes = paths . map ( ( path ) => {
1618 const ext = extname ( path ) ;
17- const name = basename ( path , ext )
19+ const name = basename ( path , ext ) ;
1820 const content = readFileSync ( path , { encoding : "utf-8" } ) ;
1921 const ast = ctx . parseMyst ( content ) ;
20- const frontmatter = getFrontmatter ( vfile , ast ) . frontmatter ;
22+ const frontmatter = validatePageFrontmatter (
23+ getFrontmatter ( vfile , ast ) . frontmatter ,
24+ {
25+ property : "frontmatter" ,
26+ file : vfile . path ,
27+ messages : { } ,
28+ errorLogFn : ( message ) => {
29+ fileError ( vfile , message , {
30+ ruleId : RuleId . validPageFrontmatter ,
31+ } ) ;
32+ } ,
33+ warningLogFn : ( message ) => {
34+ fileWarn ( vfile , message , {
35+ ruleId : RuleId . validPageFrontmatter ,
36+ } ) ;
37+ } ,
38+ } ,
39+ ) ;
2140 const descriptionItems = frontmatter . description
2241 ? ctx . parseMyst ( frontmatter . description ) . children
2342 : [ ] ;
@@ -29,7 +48,9 @@ const blogPostsDirective = {
2948 {
3049 type : "footer" ,
3150 // Pull out the first child of `root` node.
32- children : [ ctx . parseMyst ( `**Date**: ${ frontmatter . date } ` ) [ "children" ] [ 0 ] ] ,
51+ children : [
52+ ctx . parseMyst ( `**Date**: ${ frontmatter . date } ` ) [ "children" ] [ 0 ] ,
53+ ] ,
3354 } ,
3455 ]
3556 : [ ] ;
0 commit comments