Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit cf6af12

Browse files
authored
Merge pull request #1 from okaryo/refine/card-style-when-mobile
Refine thumbnail style on mobile
2 parents 0a857ea + 3b7e784 commit cf6af12

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ You can apply custom styles to the classes specified within the link card to cus
7777
.gatsby-remark-link-card__url {}
7878

7979
.gatsby-remark-link-card__thumbnail {}
80+
81+
.gatsby-remark-link-card__image {}
8082
```

src/gatsby-ssr.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const onRenderBody = ({ setHeadComponents }) => {
1515
.gatsby-remark-link-card__link {
1616
display: flex;
1717
align-items: center;
18+
justify-content: space-between;
1819
font-size: 16.5px;
1920
line-height: 1.5;
2021
text-decoration: none;
@@ -28,6 +29,17 @@ export const onRenderBody = ({ setHeadComponents }) => {
2829
line-height: 1.5;
2930
padding: 16px;
3031
width: 100%;
32+
flex-shrink: 0;
33+
}
34+
35+
.gatsby-remark-link-card__main:has(+ .gatsby-remark-link-card__thumbnail) {
36+
width: 60%;
37+
}
38+
39+
@media (min-width: 768px) {
40+
.gatsby-remark-link-card__main:has(+ .gatsby-remark-link-card__thumbnail) {
41+
width: 70%;
42+
}
3143
}
3244
3345
.gatsby-remark-link-card__content {}
@@ -79,9 +91,14 @@ export const onRenderBody = ({ setHeadComponents }) => {
7991
}
8092
8193
.gatsby-remark-link-card__thumbnail {
82-
display: block;
83-
height: 128px !important;
84-
width: auto !important;
94+
height: 128px;
95+
}
96+
97+
.gatsby-remark-link-card__image {
98+
margin: 0 !important;
99+
height: 100% !important;
100+
width: 100% !important;
101+
object-fit: cover;
85102
}
86103
`;
87104

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ const createLinkCardNode = (
7777
]),
7878
]),
7979
ogImageUrl
80-
? h("img", {
81-
src: ogImageUrl,
82-
className: className("thumbnail"),
83-
alt: "ogImage",
84-
})
80+
? h("div", { className: className("thumbnail") }, [
81+
h("img", {
82+
src: ogImageUrl,
83+
className: className("image"),
84+
alt: "ogImage",
85+
}),
86+
])
8587
: h("div"),
8688
],
8789
),

0 commit comments

Comments
 (0)