Skip to content

Commit

Permalink
chore: update imports from article page
Browse files Browse the repository at this point in the history
  • Loading branch information
jonyw4 committed Nov 13, 2021
1 parent b9008f6 commit f531581
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions webapp/src/pages/articles/[slug].tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 (
<ArticlePage title={title} createdAt={createdAt} updatedAt={updatedAt}>
<Markdown content={content}/>
<Markdown content={content} />
</ArticlePage>
);
}

let articleRepository: ArticleRepository = new ArticleFileSystemRepository();

export const getStaticProps: GetStaticProps<ArticleProps> = async ({ params }) => {
export const getStaticProps: GetStaticProps<ArticleProps> = 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)),
},
};
};
Expand All @@ -40,4 +47,4 @@ export const getStaticPaths: GetStaticPaths = async () => {
paths: articleSlugs.map((slug) => ({ params: { slug } })),
fallback: false,
};
};
};

1 comment on commit f531581

@vercel
Copy link

@vercel vercel bot commented on f531581 Nov 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.