has_attachments.html 1.1 KB

1234567891011121314151617181920212223
  1. {{/* Return true if the page has attachments or link buttons to display. */}}
  2. {{ $page := . }}
  3. {{ $pdf_link := false }}
  4. {{/* Prevent Hugo warning ".File.ContentBaseName on zero object." for content not backed by a Markdown file, */}}
  5. {{/* such as auto-generated taxonomy pages, and sections without an explicit index file. */}}
  6. {{/* The file check is required when called from `_default/list.html`, the fallback list view for the above cases. */}}
  7. {{ with $page.File }}
  8. {{ $slug := $page.File.ContentBaseName }}
  9. {{ $resource := $page.Resources.GetMatch (printf "%s.pdf" $slug) }}
  10. {{ with $resource }}
  11. {{ $pdf_link = true }}
  12. {{ end }}
  13. {{ end }}
  14. {{ $cite_link := false }}
  15. {{ $resource := $page.Resources.GetMatch "cite.bib" }}
  16. {{ with $resource }}
  17. {{ $cite_link = true }}
  18. {{ end }}
  19. {{ return ($cite_link | or $pdf_link | or .Params.url_preprint | or .Params.url_pdf | or .Params.url_slides | or .Params.url_video | or .Params.url_source | or .Params.url_code | or .Params.url_dataset | or .Params.url_poster | or .Params.url_project | or .Params.doi | or .Params.links | or .Params.projects | or .Params.slides) }}