Skip to content

Commit 2bd6efa

Browse files
committed
feat: support showing description of preview image
Also moved the image position to the metadata area
1 parent 135a16f commit 2bd6efa

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

_layouts/post.html

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,9 @@
1111

1212
{% include lang.html %}
1313

14-
{% if page.image.path %}
15-
{% capture bg %}
16-
{% unless page.image.no_bg %}{{ 'bg' }}{% endunless %}
17-
{% endcapture %}
18-
<img src="{{ page.image.path }}" class="preview-img {{ bg | strip }}"
19-
alt="{{ page.image.alt | default: "Preview Image" }}"
20-
21-
{% if page.image.width %}
22-
width="{{ page.image.width }}"
23-
{% elsif page.image.w %}
24-
width="{{ page.image.w }}"
25-
{% endif %}
26-
27-
{% if page.image.height %}
28-
height="{{ page.image.height }}"
29-
{% elsif page.image.h %}
30-
height="{{ page.image.h }}"
31-
{% endif %}>
32-
{% endif %}
33-
3414
<h1 data-toc-skip>{{ page.title }}</h1>
3515

3616
<div class="post-meta text-muted">
37-
38-
<div>
3917
<!-- published date -->
4018
<span>
4119
{{ site.data.locales[lang].post.posted }}
@@ -49,7 +27,34 @@ <h1 data-toc-skip>{{ page.title }}</h1>
4927
{% include datetime.html date=page.last_modified_at tooltip=true %}
5028
</span>
5129
{% endif %}
52-
</div>
30+
31+
{% if page.image.path %}
32+
{% capture bg %}
33+
{% unless page.image.no_bg %}{{ 'bg' }}{% endunless %}
34+
{% endcapture %}
35+
36+
<div class="mt-3 mb-3">
37+
<img src="{{ page.image.path }}" class="preview-img {{ bg | strip }}"
38+
alt="{{ page.image.alt | default: "Preview Image" }}"
39+
40+
{% if page.image.width %}
41+
width="{{ page.image.width }}"
42+
{% elsif page.image.w %}
43+
width="{{ page.image.w }}"
44+
{% endif %}
45+
46+
{% if page.image.height %}
47+
height="{{ page.image.height }}"
48+
{% elsif page.image.h %}
49+
height="{{ page.image.h }}"
50+
{% endif %}>
51+
52+
{% if page.image.alt %}
53+
<figcaption class="pt-2 pb-2">{{ page.image.alt }}</figcaption>
54+
{% endif %}
55+
56+
</div>
57+
{% endif %}
5358

5459
<div class="d-flex justify-content-between">
5560
<!-- author -->

_sass/addon/commons.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ img[data-src] {
441441
margin-right: 2px;
442442
}
443443

444-
&:hover {
444+
&:not([class]):hover {
445445
@extend %link-hover;
446446
}
447447
}

_sass/layout/post.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ h1 + .post-meta {
4141
}
4242

4343
img.preview-img {
44-
margin-top: 3.75rem;
45-
margin-bottom: 0;
44+
margin: 0;
4645
border-radius: 6px;
4746

4847
&.bg[data-loaded=true] {

0 commit comments

Comments
 (0)