content/static: add analytics attributes to search results
Trust: Jamal Carvalho
Run-TryBot: Jamal Carvalho
TryBot-Result: kokoro
{{else}}
<div>{{/* Containing element is needed to use *-of-type selectors */}}
{{$query := .Query}}
- {{range .Results}}
+ {{range $i, $v := .Results}}
<div class="SearchSnippet">
<h2 class="SearchSnippet-header">
- <a href="/{{.PackagePath}}" data-test-id="snippet-title">{{.PackagePath}}</a>
+ <a href="/{{$v.PackagePath}}" data-gtmc="search result" data-gtmv="{{$i}}"
+ data-test-id="snippet-title">
+ {{$v.PackagePath}}
+ </a>
</h2>
- <p class="SearchSnippet-synopsis" data-test-id="snippet-synopsis">{{.Synopsis}}</p>
+ <p class="SearchSnippet-synopsis" data-test-id="snippet-synopsis">{{$v.Synopsis}}</p>
<div class="SearchSnippet-infoLabel">
<b class="InfoLabel-title">Version:</b>
- <span data-test-id="snippet-version"> {{.DisplayVersion}}</span>
+ <span data-test-id="snippet-version"> {{$v.DisplayVersion}}</span>
<span class="InfoLabel-divider">|</span>
<b class="InfoLabel-title">Published:</b>
- <span data-test-id="snippet-published"> {{.CommitTime}}</span>
+ <span data-test-id="snippet-published"> {{$v.CommitTime}}</span>
<span class="InfoLabel-divider">|</span>
<b class="InfoLabel-title">Imported by:</b>
- <span data-test-id="snippet-importedby"> {{.NumImportedBy}}</span>
+ <span data-test-id="snippet-importedby"> {{$v.NumImportedBy}}</span>
<span class="InfoLabel-divider">|</span>
- <b class="InfoLabel-title">{{pluralize (len .Licenses) "License"}}:</b>
+ <b class="InfoLabel-title">{{pluralize (len $v.Licenses) "License"}}:</b>
<span data-test-id="snippet-license">
- {{if .Licenses}}
- {{commaseparate .Licenses}}
+ {{if $v.Licenses}}
+ {{commaseparate $v.Licenses}}
{{else}}
<span>N/A</span>
{{end}}
