Skip to content

Commit af1273d

Browse files
committed
adding inline image capability
1 parent c3fd7a4 commit af1273d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/routes/blog/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ function CodeBlock(props) {
2727
);
2828
}
2929

30+
function InlineImage({ alt, title, src }) {
31+
return (
32+
<div class={style.inlineImageContainer}>
33+
<img class={style.inlineImage} src={src} alt={alt} />
34+
{title && <span class={style.inlineImageTitle}>{title}</span>}
35+
</div>
36+
);
37+
}
38+
3039
function getBlogBody(data, isLoading) {
3140
if (isLoading) {
3241
return (
@@ -52,6 +61,9 @@ function getBlogBody(data, isLoading) {
5261
<div class={style.blogbody}>
5362
<Markdown options={{
5463
overrides: {
64+
img: {
65+
component: InlineImage
66+
},
5567
code: {
5668
component: CodeBlock
5769
}

src/routes/blog/style.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,22 @@ code.inline {
105105
.loadingBody:nth-child(3) {
106106
width: 65%;
107107
}
108+
109+
.inlineImageContainer{
110+
display: flex;
111+
flex-direction: column;
112+
justify-content: center;
113+
align-items: center;
114+
width: 80%;
115+
margin: 32px auto;
116+
}
117+
118+
.inlineImage {
119+
max-width: 100%;
120+
}
121+
122+
.inlineImageTitle {
123+
font-size: 0.8rem;
124+
margin-top: 8px;
125+
color: #777;
126+
}

0 commit comments

Comments
 (0)