|
8 | 8 | {% assign citation = include %} |
9 | 9 | {% endif %} |
10 | 10 |
|
| 11 | +{% assign citation_pdf = citation.pdf | default: nil %} |
| 12 | +{% if citation_pdf == nil and citation.buttons.size > 0 %} |
| 13 | + {% for button in citation.buttons %} |
| 14 | + {% assign button_link = button.link | default: "" | downcase %} |
| 15 | + {% assign button_text = button.text | default: "" | downcase %} |
| 16 | + {% assign button_icon = button.icon | default: "" | downcase %} |
| 17 | + {% assign is_pdf_link = button_link contains ".pdf" %} |
| 18 | + {% assign is_pdf_text = button_text contains "pdf" %} |
| 19 | + {% assign is_pdf_icon = button_icon contains "pdf" %} |
| 20 | + {% if is_pdf_link or is_pdf_text or is_pdf_icon %} |
| 21 | + {% assign citation_pdf = button.link %} |
| 22 | + {% break %} |
| 23 | + {% endif %} |
| 24 | + {% endfor %} |
| 25 | +{% endif %} |
| 26 | + |
11 | 27 | <div class="citation-container"> |
12 | 28 | <div class="citation"> |
13 | 29 | {% if include.style == "rich" %} |
14 | 30 | <a |
15 | | - {% if citation.link %} |
| 31 | + {% if citation_pdf %} |
| 32 | + href="{{ citation_pdf | relative_url | uri_escape }}" |
| 33 | + {% elsif citation.link %} |
16 | 34 | href="{{ citation.link | relative_url | uri_escape }}" |
17 | 35 | {% endif %} |
18 | 36 | class="citation-image" |
19 | 37 | aria-label="{{ citation.title | default: "citation link" | regex_strip }}" |
20 | 38 | > |
21 | | - <img |
22 | | - src="{{ citation.image | relative_url | uri_escape }}" |
23 | | - alt="{{ citation.title | default: "citation image" | regex_strip }}" |
24 | | - loading="lazy" |
25 | | - {% include fallback.html %} |
26 | | - > |
| 39 | + {% if citation_pdf %} |
| 40 | + {% include pdf-preview.html pdf=citation_pdf image=citation.image title=citation.title %} |
| 41 | + {% else %} |
| 42 | + <img |
| 43 | + src="{{ citation.image | relative_url | uri_escape }}" |
| 44 | + alt="{{ citation.title | default: "citation image" | regex_strip }}" |
| 45 | + loading="lazy" |
| 46 | + {% include fallback.html %} |
| 47 | + > |
| 48 | + {% endif %} |
27 | 49 | </a> |
28 | 50 | {% endif %} |
29 | 51 |
|
|
0 commit comments