page_links.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. {{ $is_list := .is_list }}
  2. {{ $ := .content }}
  3. {{ $link := "" }}
  4. {{ with $.Params.url_preprint }}
  5. {{ $resource := $.Resources.GetMatch . }}
  6. {{ if $resource }}
  7. {{ $link = $resource.RelPermalink }}
  8. {{ else }}
  9. {{ $link = . | relURL }}
  10. {{ end }}
  11. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
  12. {{ i18n "btn_preprint" }}
  13. </a>
  14. {{ end }}
  15. {{ $pdf := "" }}
  16. {{ $resource := $.Resources.GetMatch (printf "%s.pdf" $.File.ContentBaseName) }}
  17. {{ with $resource }}
  18. {{ $pdf = .RelPermalink }}
  19. {{ else }}
  20. {{ if $.Params.url_pdf }}
  21. {{ $pdf = $.Params.url_pdf | relURL }}
  22. {{ end }}
  23. {{ end }}
  24. {{ with $pdf }}
  25. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . }}" target="_blank" rel="noopener">
  26. {{ i18n "btn_pdf" }}
  27. </a>
  28. {{ end }}
  29. {{ $resource := $.Resources.GetMatch "*.bib" }}
  30. {{ with $resource }}
  31. <button type="button" class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}} js-cite-modal"
  32. data-filename="{{ .RelPermalink }}">
  33. {{ i18n "btn_cite" }}
  34. </button>
  35. {{ end }}
  36. {{ with $.Params.url_code }}
  37. {{ $resource := $.Resources.GetMatch . }}
  38. {{ if $resource }}
  39. {{ $link = $resource.RelPermalink }}
  40. {{ else }}
  41. {{ $link = . | relURL }}
  42. {{ end }}
  43. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
  44. {{ i18n "btn_code" }}
  45. </a>
  46. {{ end }}
  47. {{ with $.Params.url_dataset }}
  48. {{ $resource := $.Resources.GetMatch . }}
  49. {{ if $resource }}
  50. {{ $link = $resource.RelPermalink }}
  51. {{ else }}
  52. {{ $link = . | relURL }}
  53. {{ end }}
  54. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
  55. {{ i18n "btn_dataset" }}
  56. </a>
  57. {{ end }}
  58. {{ if $.Params.projects }}
  59. {{ range $.Params.projects }}
  60. {{ with ($.Site.GetPage (printf "project/%s" .)) }}
  61. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .RelPermalink }}">
  62. {{ i18n "btn_project" }}
  63. </a>
  64. {{ else }}
  65. {{/* 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 . */}}
  66. {{ end }}
  67. {{ end }}
  68. {{ else }}
  69. {{ with $.Params.url_project }}
  70. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . }}" target="_blank" rel="noopener">
  71. {{ i18n "btn_project" }}
  72. </a>
  73. {{ end }}
  74. {{ end }}
  75. {{ with $.Params.url_poster }}
  76. {{ $resource := $.Resources.GetMatch . }}
  77. {{ if $resource }}
  78. {{ $link = $resource.RelPermalink }}
  79. {{ else }}
  80. {{ $link = . | relURL }}
  81. {{ end }}
  82. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
  83. {{ i18n "btn_poster" }}
  84. </a>
  85. {{ end }}
  86. {{ if $.Params.slides }}
  87. {{ with ($.Site.GetPage (printf "slides/%s" $.Params.slides)) }}
  88. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .RelPermalink }}" target="_blank">
  89. {{ i18n "btn_slides" }}
  90. </a>
  91. {{ end }}
  92. {{ else }}
  93. {{ with $.Params.url_slides }}
  94. {{ $resource := $.Resources.GetMatch . }}
  95. {{ if $resource }}
  96. {{ $link = $resource.RelPermalink }}
  97. {{ else }}
  98. {{ $link = . | relURL }}
  99. {{ end }}
  100. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
  101. {{ i18n "btn_slides" }}
  102. </a>
  103. {{ end }}
  104. {{ end }}
  105. {{ with $.Params.url_video }}
  106. {{ $resource := $.Resources.GetMatch . }}
  107. {{ if $resource }}
  108. {{ $link = $resource.RelPermalink }}
  109. {{ else }}
  110. {{ $link = . | relURL }}
  111. {{ end }}
  112. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
  113. {{ i18n "btn_video" }}
  114. </a>
  115. {{ end }}
  116. {{ with $.Params.url_source }}
  117. {{ $resource := $.Resources.GetMatch . }}
  118. {{ if $resource }}
  119. {{ $link = $resource.RelPermalink }}
  120. {{ else }}
  121. {{ $link = . | relURL }}
  122. {{ end }}
  123. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
  124. {{ i18n "btn_source" }}
  125. </a>
  126. {{ end }}
  127. {{ with $.Params.doi }}
  128. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="https://doi.org/{{ . }}" target="_blank" rel="noopener">
  129. DOI
  130. </a>
  131. {{ end }}
  132. {{ range $.Params.url_custom }}
  133. {{ $pack := or .icon_pack "fas" }}
  134. {{ $pack_prefix := $pack }}
  135. {{ if in (slice "fab" "fas" "far" "fal") $pack }}
  136. {{ $pack_prefix = "fa" }}
  137. {{ end }}
  138. {{ $link := .url }}
  139. {{ $scheme := (urls.Parse $link).Scheme }}
  140. {{ $target := "" }}
  141. {{ if not $scheme }}
  142. {{ $resource := $.Resources.GetMatch .url }}
  143. {{ if $resource }}
  144. {{ $link = $resource.RelPermalink }}
  145. {{ else }}
  146. {{ $link = .url | relURL }}
  147. {{ end }}
  148. {{ else if in (slice "http" "https") $scheme }}
  149. {{ $target = "target=\"_blank\" rel=\"noopener\"" }}
  150. {{ end }}
  151. <a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>
  152. {{ if .icon }}<i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }} {{if .name}}mr-1{{end}}"></i>{{end}}
  153. {{ with .name }}{{ . | safeHTML }}{{end}}
  154. </a>
  155. {{ end }}