Skip to content

Commit 3a97f94

Browse files
committed
Try to show article preview in icon
1 parent 417f300 commit 3a97f94

4 files changed

Lines changed: 55 additions & 7 deletions

File tree

_includes/citation.html

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,44 @@
88
{% assign citation = include %}
99
{% endif %}
1010

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+
1127
<div class="citation-container">
1228
<div class="citation">
1329
{% if include.style == "rich" %}
1430
<a
15-
{% if citation.link %}
31+
{% if citation_pdf %}
32+
href="{{ citation_pdf | relative_url | uri_escape }}"
33+
{% elsif citation.link %}
1634
href="{{ citation.link | relative_url | uri_escape }}"
1735
{% endif %}
1836
class="citation-image"
1937
aria-label="{{ citation.title | default: "citation link" | regex_strip }}"
2038
>
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 %}
2749
</a>
2850
{% endif %}
2951

_includes/pdf-preview.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% if include.pdf %}
2+
<object
3+
data="{{ include.pdf | relative_url | uri_escape }}#page=1&view=FitH"
4+
type="application/pdf"
5+
aria-label="{{ include.title | default: 'PDF preview' | regex_strip }}"
6+
>
7+
<img
8+
src="{{ include.image | relative_url | uri_escape }}"
9+
alt="{{ include.title | default: 'preview image' | regex_strip }}"
10+
loading="lazy"
11+
{% include fallback.html %}
12+
>
13+
</object>
14+
{% endif %}

_includes/poster-list.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
{% for poster in posters %}
33
<div class="citation-container">
44
<div class="citation">
5+
<a href="{{ poster.pdf | relative_url }}" target="_blank" class="citation-image" aria-label="{{ poster.title | default: 'poster link' | regex_strip }}">
6+
{% include pdf-preview.html pdf=poster.pdf image=poster.image title=poster.title %}
7+
</a>
58
<div class="citation-text">
69
{% include icon.html icon="fa-solid fa-chalkboard" %}
710
<a href="{{ poster.pdf | relative_url }}" target="_blank" class="citation-title">{{ poster.title }}</a>

_styles/citation.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ $wrap: 800px;
3232
object-fit: contain;
3333
}
3434

35+
.citation-image object {
36+
position: absolute;
37+
inset: 0;
38+
width: 100%;
39+
height: 100%;
40+
border: 0;
41+
pointer-events: none;
42+
}
43+
3544
.citation-text {
3645
position: relative;
3746
display: inline-flex;

0 commit comments

Comments
 (0)