fd8cc6bdfc18aff40df2dfb6b7131ae482c5609a
[theme-danix.xyz.git] / layouts / partials / breadcrumbs.html
1 <ol class="crumbs" itemscope itemtype="https://schema.org/BreadcrumbList">
2 {{- /* declare a 'variable' to store the each link position */}}
3 {{- $data := newScratch }}
4
5 {{- range $index, $value := .Ancestors.Reverse }}
6 <li class="crumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
7 {{- /* read the index from loop and add 'one', because it starts counting from zero */}}
8 {{- $data.Set "counter" $index }}
9 {{- $data.Add "counter" 1 }}
10 <a itemprop="item" href="{{.Permalink}}">
11 {{ if .IsHome }}
12 <span itemprop="name">home</span>
13 {{ else }}
14 <span itemprop="name">{{.Title}}</span>
15 {{ end }}
16 </a>
17 {{- /* pass the counter value into schema attribute */}}
18 <meta itemprop="position" content='{{ $data.Get "counter"}}' />
19 </li>
20 {{- end }}
21 <li class="crumb-item active" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
22 {{- /* add 'one' one more time for the last link position */}}
23 {{- $data.Add "counter" 1 }}
24 <span itemprop="name">{{.Title}}</span>
25 {{- /* pass the counter value into schema attribute */}}
26 <meta itemprop="position" content='{{ $data.Get "counter"}}' />
27 </li>
28 </ol>