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