Ways We Avoid Hard Validation
Slugs
Our content team does not reliably have slug properties in frontmatter. Unitl they solve for that, we must generate a slug from the filename.
Slugs are generated from the filename. This is most reliably performed from using the filesystem to get the actual path, then removing the part of the string that comes before the last "/", then popping the extension off the end of the string. Then we need to assure there are no " " space characters, by replacing them with "-" if they are present. Then we need to lowercase the string.
Strings to Arrays
Our content team sometimes uses strings as values where they should be arrays. We must normalize these to arrays. "tags" is the most common example. However, "authors" and "categories" are also examples.
With authors and categories, sometimes the key value is singular rather than plural. For example, "author" or "category". We must see "categories" and "category" as the same key, and normalize the value to an array. We must see "author" and "authors" as the same key, and normalize the value to an array.