Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

コンポーネント分割 #8

Merged
merged 1 commit into from
May 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions frontend/components/ArticleContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import dayjs from '@/lib/dayjs'

type Props = {
content: string
date: dayjs.Dayjs
title: string
}

const ArticleContent = ({ content, title, date }: Props) => {
return (
<article>
<small>{date.format('YYYY-MM-DD')}</small>
<h1>{title}</h1>
<div dangerouslySetInnerHTML={{ __html: content }} />
</article>
)
}

export default ArticleContent
5 changes: 2 additions & 3 deletions frontend/pages/posts/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ArticleContent from '@/components/ArticleContent'
import dayjs from '@/lib/dayjs'
import * as postService from '@/services/post-service'

Expand Down Expand Up @@ -35,9 +36,7 @@ type Props = {
const Slug = ({ content, title, date }: Props) => {
return (
<>
<small>{dayjs(date).format('YYYY-MM-DD')}</small>
<h1>{title}</h1>
<div dangerouslySetInnerHTML={{ __html: content }} />
<ArticleContent content={content} date={dayjs(date)} title={title} />
</>
)
}
Expand Down