-
Notifications
You must be signed in to change notification settings - Fork 163
If a post has invalid categories, it won't render #212
Comments
Thanks for reporting this, but I cannot reproduce the bug: for a post with no categories, the Can you indicate some way to reproduce it? |
Okay, so, I'm an idiot. It's not that my posts have no categories, its that Pretzel didn't pick them up because of incorrect syntax and Using the post below as context,
So the solution is for me to fix my syntax, but the only way I discovered my syntax was off was by digging into the source code of Pretzel. There isn't an error (other than I think ultimately pretzel should do a "best effort" at delivering a page rather than stopping on an error (obviously depending on the scope of the error!). I think the null value check on L400 would still be a good idea for idiots like me :D What I mean is, sure, categories shouldn't work because my syntax is off, but the rest of the page should at least render by adding that check Here is an example of the YAML front matter thats failing (the rest of the post isn't super relevant)
|
Thanks for the info. For info, you can also use the syntax: |
Fixes #212 relating to categories being null from incorrect syntax in posts
Forgive me, it's been awhile since I've used Github so I'm not sure how all the cool kids link to stuff properly anymore.
Basically if a post has no category, it'll throw a
NullReferenceException
when evaluating the permalink. The "offending" line (for lack of a better term) is this:permalink = permalink.Replace(":categories", string.Join("-", page.Categories.ToArray()));
https://github.com/Code52/pretzel/blob/master/src/Pretzel.Logic/Templating/Context/SiteContextGenerator.cs#L402
Now, I know I could send in a PR but there would be a couple of things to think about:
if (page.Categories != null)
solves the issue, easy done, right? Well, does that then necessitate a check for each of the date properties?page.Categories
isn't initialised, because in theory it is in the constructor for Page.The text was updated successfully, but these errors were encountered: