From f53158102a7e97374f108f329ae468cd15bbf77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20C=C3=A9lio?= Date: Sat, 13 Nov 2021 00:13:35 -0300 Subject: [PATCH] chore: update imports from article page --- webapp/src/pages/articles/[slug].tsx | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/webapp/src/pages/articles/[slug].tsx b/webapp/src/pages/articles/[slug].tsx index ba3a282..1443502 100644 --- a/webapp/src/pages/articles/[slug].tsx +++ b/webapp/src/pages/articles/[slug].tsx @@ -1,9 +1,9 @@ -import { ArticlePage } from "../../components/templates/ArticlePage"; -import { Markdown } from '../../components/atoms/Markdown' -import { ArticleRepository } from '../../data'; -import { ArticleFileSystemRepository } from '../../infra' import { GetStaticProps, GetStaticPaths } from "next"; +import { ArticlePage } from "../../components/templates/ArticlePage"; +import { Markdown } from "../../components/atoms/Markdown"; import { formatDate } from "../../components/global/formatDate"; +import { ArticleRepository } from "../../data"; +import { ArticleFileSystemRepository } from "../../infra"; export interface ArticleProps { content: string; @@ -12,24 +12,31 @@ export interface ArticleProps { updatedAt: string; } -export default function Article({ content, title, createdAt, updatedAt }: ArticleProps) { +export default function Article({ + content, + title, + createdAt, + updatedAt, +}: ArticleProps) { return ( - + ); } let articleRepository: ArticleRepository = new ArticleFileSystemRepository(); -export const getStaticProps: GetStaticProps = async ({ params }) => { +export const getStaticProps: GetStaticProps = async ({ + params, +}) => { const slug = params?.slug as string; const article = await articleRepository.findArticleBySlug(slug); return { props: { - ...article, - createdAt: formatDate(new Date(article.createdAt)), - updatedAt: formatDate(new Date(article.updatedAt)) + ...article, + createdAt: formatDate(new Date(article.createdAt)), + updatedAt: formatDate(new Date(article.updatedAt)), }, }; }; @@ -40,4 +47,4 @@ export const getStaticPaths: GetStaticPaths = async () => { paths: articleSlugs.map((slug) => ({ params: { slug } })), fallback: false, }; -}; \ No newline at end of file +};