Skip to content

Commit d0d0780

Browse files
committed
Added caption sytle for hyperlinked images (cotes2020#144).
1 parent bbb81b5 commit d0d0780

3 files changed

Lines changed: 50 additions & 17 deletions

File tree

assets/css/_addon/main.scss

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -816,30 +816,45 @@ div.post-content .table-wrapper {
816816
margin-top: 2rem;
817817
overflow-wrap: break-word;
818818
word-wrap: break-word;
819-
a {
820-
@extend %link-color;
821-
@extend %link-underline;
822-
&:hover {
823-
@extend %link-hover;
824-
}
825-
}
826-
p {
827-
font-size: 1.08rem;
819+
820+
@mixin img {
828821
> img {
829822
&:not([style]) {
830823
margin: .5rem 0;
831824
@include align-center;
832-
+ em {
833-
display: block;
834-
text-align: center;
835-
font-style: normal;
836-
font-size: 80%;
837-
padding: 0;
838-
color: #6d6c6c;
839-
}
825+
@include img-caption;
826+
}
827+
}
828+
}
840829

830+
@mixin img-caption {
831+
+ em {
832+
display: block;
833+
text-align: center;
834+
font-style: normal;
835+
font-size: 80%;
836+
padding: 0;
837+
color: #6d6c6c;
838+
}
839+
}
840+
841+
a {
842+
&:not(.img-hyperlink) {
843+
@extend %link-color;
844+
@extend %link-underline;
845+
&:hover {
846+
@extend %link-hover;
841847
}
842848
}
849+
&.img-hyperlink {
850+
@include img;
851+
@include img-caption;
852+
}
853+
}
854+
855+
p {
856+
font-size: 1.08rem;
857+
@include img;
843858
}// p
844859
}
845860

assets/js/_utils/img-hyperlink.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Find out the <a> tag contains an image and mark it.
3+
*
4+
* v2.5.1
5+
* https://github.com/cotes2020/jekyll-theme-chirpy
6+
* © 2020 Cotes Chung
7+
* MIT Licensed
8+
*/
9+
10+
$(function() {
11+
12+
var MARK="img-hyperlink";
13+
14+
$("a:has(img)").addClass(MARK);
15+
16+
});

assets/js/post.min.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ layout: compress
1313
{% include_relative lib/_bootstrap-toc.min.js %}
1414

1515
{% include_relative _utils/toc-filter.js %}
16+
17+
{% include_relative _utils/img-hyperlink.js %}

0 commit comments

Comments
 (0)