I’m hitting a massive wall with the following challenge. I have searched the forum and read some really complicated slice, map, index, and append docs and tutorials, but it goes way over my head. Thank you for your time & effort.
My data directory looks like this:
/data
/movies
warner.json
universal.json
/arthouse
searchlight.json
drafthouse.json
And I use the following code to:
- range through one folder and files in /data
- Show only movies from movie star X
Example: On brad-pitt-movie-star.html I display the movies he played in. I usedif in .data.stars $star
, which ranges through all the stars from movies and if Brad was in it, it will match and display. The$star
is set usingScratch
and passed along toif in
{{ $model := .Scratch.Set "starpage" .Title }}
{{ $star := .Scratch.Get "starpage" }}
{{ range $parentKey, $parent := .Site.Data.movie }}
{{ range $childKey, $child := sort . ".data.views" "desc" }}
{{ if in .data.stars $star }}
{{ .data.title }}
{{ end }}
{{ end }}
{{ end }}
range first 15
Where do I add first
like in range first 15 .Site.Data.movie
. I have tried a variety of positions. Do you have an idea?