Skip to content

Commit eaae84f

Browse files
authored
Show poster preview as icon (#47)
1 parent 417f300 commit eaae84f

File tree

4 files changed

+60
-10
lines changed

4 files changed

+60
-10
lines changed

_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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
{% if include.image %}
8+
<img
9+
src="{{ include.image | relative_url | uri_escape }}"
10+
alt="{{ include.title | default: 'preview image' | regex_strip }}"
11+
loading="lazy"
12+
{% include fallback.html %}
13+
>
14+
{% endif %}
15+
</object>
16+
{% endif %}

_includes/poster-list.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
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+
{% assign poster_image = poster.image | default: '/assets/img/poster-placeholder.png' %}
7+
{% include pdf-preview.html pdf=poster.pdf image=poster_image title=poster.title %}
8+
</a>
59
<div class="citation-text">
610
{% include icon.html icon="fa-solid fa-chalkboard" %}
711
<a href="{{ poster.pdf | relative_url }}" target="_blank" class="citation-title">{{ poster.title }}</a>

_styles/citation.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ $wrap: 800px;
2424
// box-shadow: var(--shadow);
2525
}
2626

27-
.citation-image img {
27+
.citation-image {
28+
position: relative;
29+
width: $thumb-size;
30+
flex-shrink: 0;
31+
overflow: hidden; // add this
32+
}
33+
34+
.citation-image object {
2835
position: absolute;
2936
inset: 0;
30-
width: 100%;
37+
width: calc(100% + 20px); // push scrollbar outside clip boundary
3138
height: 100%;
32-
object-fit: contain;
39+
border: 0;
40+
pointer-events: none;
3341
}
3442

3543
.citation-text {

0 commit comments

Comments
 (0)