8000 refactor/ Refatorado o Post. · lostcode-dev/lostcode-blog@58892f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 58892f9

Browse files
committed
refactor/ Refatorado o Post.
1 parent 18d9027 commit 58892f9

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

src/helpers/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export const getContent = (post) => {
3838
return content.map(el => {
3939
return {
4040
...el,
41-
paragraph: RichText.asHtml(el.paragraph),
42-
title: RichText.asText(el.title),
41+
paragraph: RichText.asHtml(el.paragraph) ?? '',
42+
title: RichText.asText(el.title) ?? '',
4343
}
4444
});
4545
}

src/pages/posts/[slug].tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ export default function Post({ post }: P 8000 ostProps) {
3232
<article className={styles.post}>
3333
<h1>{post.title}</h1>
3434
<time>{post.updatedAt}</time>
35-
<img src={post.image_banner} alt={post.title} />
35+
<img className={post.image_banner} src={post.image_banner} alt={post.title} />
3636
<div className={styles.postContent} dangerouslySetInnerHTML={{ __html: post.introduction }} />
3737

3838
{post.content.map(content => (
39-
<div key={post.title}>
40-
<h3>{post.title}</h3>
39+
<div key={content.title}>
40+
<div>
41+
<img src={content.image_content.url} height={content.image_content.dimensions.height} alt={content.image_content.alt} />
42+
<p className={styles.caption}>{ content.image_content.alt }</p>
43+
</div>
44+
{content.title && <h4>{content.title}</h4>}
4145
<div className={styles.postContent} dangerouslySetInnerHTML={{ __html: content.paragraph }} />
4246
</div>
4347
))}

src/pages/posts/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GetStaticProps } from 'next';
22
import Prismic from '@prismicio/client';
33
import { api_id, GET_PRISMIC_CLIENT, LIST_POST_PRISMIC, PARAMS_DAFAULT_PRISMIC, SEARCH_LIST_POST_PRISMIC } from '../../services/prismic';
4-
import { Search, ButtonScrollTop, Tag, NotData, Loading } from '../../components';
4+
import { Search, ButtonScrollTop, NotData, Loading } from '../../components';
55
import { dateToPtbr, getImgUrl, getPreviewText, getTag, getTitle, getUid } from '../../helpers/util';
66
import styles from './styles.module.scss';
77
import { useState } from 'react';

src/pages/posts/post.module.scss

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99

1010
.post {
1111
max-width: 720px;
12-
padding-top: 5rem;
12+
padding-top: 3rem;
1313
margin: 0rem auto 0;
14+
15+
.image_banner {
16+
height: 15vh;
17+
}
1418

1519
img {
1620
object-fit: cover;
1721
width: 100%;
18-
height: 15vh;
1922
margin-top: 2rem;
23+
margin-bottom: 2rem;
2024
}
2125

2226
h1 {
@@ -34,6 +38,11 @@
3438
font-weight: 900;
3539
}
3640

41+
h4 {
42+
font-size: 1.5rem;
43+
font-weight: 900;
44+
}
45+
3746
time {
3847
display: block;
3948
font-size: 1rem;
@@ -69,4 +78,14 @@
6978
font-size: 2rem;
7079
}
7180
}
81+
82+
.caption {
83+
line-height: 20px;
84+
text-align: center;
85+
font-weight: 400;
86+
87+
position: relative;
88+
font-size: 14px;
89+
top: -20px;
90+
}
7291
}

0 commit comments

Comments
 (0)
0