{{- $section_children := (index $.children $.context.Section) -}} {{- range $pg := (cond $.sort_by_weight $.regularpages.ByWeight $.regularpages.ByTitle) -}} {{- $show_page := (cond $.sort_by_weight (cond $.weighted_top (and (lt .Params.weight 100) (ne .Params.weight nil) ) (gt .Params.weight 100) ) (or (eq .Params.weight 100) (eq .Params.weight nil) ) ) -}} {{- if (and $show_page .File $.context.File $.pagecontext.File) -}} {{- $filepath := replace (print .File.Dir (replace .File.BaseFileName "_index" "") "/") "//" "/" -}} {{- $contextfilepath := replace (print $.context.File.Dir (replace $.context.File.BaseFileName "_index" "") "/") "//" "/" -}} {{- $has_children := (in ($section_children) $filepath) -}} {{- if eq (len (split $filepath "/")) (add (len (split $contextfilepath "/")) 1) -}} {{- if and (in $filepath $contextfilepath) (ne $contextfilepath $filepath) -}}