{{ $is_list := .is_list }}
{{ $ := .content }}

{{ with $.Params.url_preprint }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_preprint" }}
</a>
{{ end }}
{{ with $.Params.url_pdf }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_pdf" }}
</a>
{{ end }}
{{ $directory := "static/files/citations/" }}
{{ $filename := printf "%s%s.bib" $directory $.File.TranslationBaseName }}
{{ if fileExists $filename }}
<button type="button" class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}} js-cite-modal"
        data-filename="{{ printf "files/citations/%s.bib" $.File.TranslationBaseName | relURL }}">
  {{ i18n "btn_cite" }}
</button>
{{ end }}
{{ with $.Params.url_code }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_code" }}
</a>
{{ end }}
{{ with $.Params.url_dataset }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_dataset" }}
</a>
{{ end }}
{{ if $.Params.projects }}
{{ range $.Params.projects }}
  {{ with ($.Site.GetPage (printf "project/%s" .)) }}
  <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .RelPermalink }}">
    {{ i18n "btn_project" }}
  </a>
  {{ else }}
    {{ errorf "The `projects` parameter in `content/%s` references a project file, `content/project/%s`, which cannot be found. Please either set `projects = []` or fix the reference." $.File.Path . }}
  {{ end }}
{{ end }}
{{ else }}
{{ with $.Params.url_project }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relLangURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_project" }}
</a>
{{ end }}
{{ end }}
{{ with $.Params.url_poster }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_poster" }}
</a>
{{ end }}
{{ with $.Params.url_slides }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_slides" }}
</a>
{{ end }}
{{ with $.Params.url_video }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_video" }}
</a>
{{ end }}
{{ with $.Params.url_source }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
  {{ i18n "btn_source" }}
</a>
{{ end }}
{{ with $.Params.doi }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="https://doi.org/{{ . }}" target="_blank" rel="noopener">
  DOI
</a>
{{ end }}
{{ range $.Params.url_custom }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .url | relURL }}" target="_blank" rel="noopener">
  {{ .name }}
</a>
{{ end }}
