Hello,
I’m working on a section layout template where the sub articles of this page are linked. In addition I would like to also see those articles that are not direct children, but have a specific tag set in the front matter.
My Content Structure looks like this :
content
– Other
----- Page3
------- Page3.md (tags: tag Title:‘Test’)
– Section
---- A
------ index.md (tags: tag Title:‘Section A’)
---- B
------ index.md (tags: tag Title:‘Section B’)
----_index.md (filter: tag)
– _index.md
My partial script for the section layout is in the spoiler below.
Partial
{{ if .page.Pages }}
<div>
*{{ template "section-tree-nav" .page }}*
{{ if isset .page.Params "filter" }}
{{ template "section-tree-tags" .page }}
{{ end }}
</div>
{{ end }}
{{ define "section-tree-nav" }}
{{ $visible_child_pages := where .Pages.ByTitle "Params.include_in_toc" "!=" "false" }}
{{ if $visible_child_pages }}
<ul>
{{ range $visible_child_pages }}
<li>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{ template "section-tree-nav" . }}
</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ define "section-tree-tags" }}
{{ $allpages := where .Site.Pages.ByTitle "Params.include_in_toc" "!=" "false" }}
{{ $visible_child_pages := where .Pages.ByTitle "Params.include_in_toc" "!=" "false" }}
{{ $filter := (slice .Params.filter) }}
{{/* General Problem : the pages that are already in other categories, would show up here as well*/}}
<ul>
<li>
<a>Filtered Tag '{{(index $filter 0)}}'</a>
</li>
{{ $filteredpages := where $allpages "Params.tags" "intersect" $filter}}
{{ range $filteredpages }}
<ul>
<li>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{ template "section-tree-nav" . }}
</li>
</ul>
{{ end }}
</ul>
{{ end }}
My question regarding this is now : How can I filter out the Pages that area already displayed, because they are direct children of the section page ?
The way this script is now, I see Test,Section A and Section B below the FilterTag element if I look a the section page called Section, but I only want to see the Link for Test, the element that is not a direct sub element.
Looking forward to your Suggestions