Past few days I have been reading, and coding which is somehow good for me. And the best is that I hop on to this forum, search and if not found, ask. And thank you community for being there to help me find my way out.
So here is what I am trying to do -
I have a folder under content called fruits. This folder has files like apple.md, banana.md - basically fruitname.md for the 50 odd files I have here.
The following is the front-matter that I have - example from my apple.md file :
Edits to the front-matter after @jmooring pointed out the errors.
usage_name: "Apple" scientific_name: "Malus pumila, Malus domestica, Malus sylvestris, Malus communis, Pyrus malus" taste: ["sweet", "sour", "savoury"] color: ["red", "green"] pics: "fruits"
Now, I have a problem. It might be easily resolvable if I used Tags (color and taste could be tags as far as I have understood GoHugo), but I do not want to have it done that way. Instead, I want to be able to search for fruits using a color.
If I want to find fruits that are green in color, I need to search through all MD files in fruits folder (content/fruits/) locate the field/parameter “color” and see if this list contains “green”. If so, I print the details of this fruit.
Here is where my code fails (going by the error -
wrong number of args for in: want 2 got 4
I know I should pass an array or a slice to IN but I am unable to figure out the how) -
$selcolor := "green" $listfruits = in (where $site.Pages "section" "fruits") "Params.color" "=" $selcolor
I hope this is doable with goHugo and if so how do I get the “in” working here? This is important for me to learn because the next thing I want to do the same with the taste.
Thank you for reading