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