Hello, I have a .json Data file, which contains a string array with slugs, let’s say ["red", "green", "blue"].
In my content directory I have markdown files like this: content/favorite/colors/red.md
When I loop over the ["red", "green", "blue"] array that I accessed from the .json file, how can I load the content markdown file in order to access its parameters and text? I’m only interested in loading the content from say 3 markdown files out of 1000, so would ideally fetch the file directly without any loop.
Thanks for the fast reply, the code is really great, and exactly what I need
There’s one problem though, I for some reason get nopPage when I try to show the content of {{ $thePageYouWant }} even though I’m certain the page exists (if I open e.g. localhost:1313/favorite/colors/red/ then it will load the content of the red.md file).
When I do printf then I can also see the path is correct: I’ve tried where {{ $thePage }} returned:
/favorite/colors/red.md
favorite/colors/red.md
/favorite/colors/red
favorite/colors/red
Based on the documentation you linked, I think /favorite/colors/red.md would be correct, but not sure… I should probably also mention that in my project I support multiple languages, I’m not sure if that could have any impact, but I don’t think so since I use the full path which include the language (e.g. /en/favorite/colors/red.md).
Ahh great, the problem was that I included the language in the file path, so it became e.g. /en/favorite/colors/red but removing the language so it was simply /favorite/colors/red worked. Thanks a lot