How to Raise an Exception if required front matter parameters are not set?

Hi,

I am migrating about 400+ posts from wordpress and the convertor linked here got me about 80% of the way.

I need a set of front-matter parameters required and set for all pages in these migrated posts.

Example: If the front matters looks like so

{
“title”: Mark Cuban and Donald Trump get into a Tweet War. Who Won?
“description”: “Watch this tweet war between Mark Cuban and Donald Trump spiral out of control”
}

and is missing tags and categories i.e. the actual front-matter should be like so

{
“title”: Mark Cuban and Donald Trump get into a Tweet War. Who Won?
“description”: “Watch this tweet war between Mark Cuban and Donald Trump spiral out of control”
“tags”: [ “tweet wars” ],
“categories”: [ “social” ]
}

I want to raise an exception during build so that I can go back and enter non-empty values for tags and categories.

Also am I approaching this the right way? Or is there a better way?
I know that for new posts, I can do an archtype with all the required front-matter params filled in with defaults, but this is more for existing 400+ posts that I am migrating, so I don’t miss anything. Or am I over-thinking this??

In summary, I have a list of front-matter parameters that must have values for every page / post and I want to be notified during build so that I can go back and fix it.

1 Like