diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/PostsList/PostsList.module.scss | 5 | ||||
| -rw-r--r-- | src/components/PostsList/PostsList.tsx | 36 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/components/PostsList/PostsList.module.scss b/src/components/PostsList/PostsList.module.scss new file mode 100644 index 0000000..9f78f68 --- /dev/null +++ b/src/components/PostsList/PostsList.module.scss @@ -0,0 +1,5 @@ +@use "@styles/abstracts/placeholders"; + +.wrapper { + @extend %reset-ordered-list; +} diff --git a/src/components/PostsList/PostsList.tsx b/src/components/PostsList/PostsList.tsx new file mode 100644 index 0000000..ca3e788 --- /dev/null +++ b/src/components/PostsList/PostsList.tsx @@ -0,0 +1,36 @@ +import Link from 'next/link'; +import { ArticlePreview } from '@ts/types/articles'; +import styles from './PostsList.module.scss'; + +type TitleLevel = 2 | 3 | 4 | 5 | 6; + +const PostsList = ({ + posts, + titleLevel, +}: { + posts: ArticlePreview[]; + titleLevel: TitleLevel; +}) => { + const TitleTag = `h${titleLevel}` as keyof JSX.IntrinsicElements; + + const postsList = posts.map((post) => { + return ( + <li key={post.id}> + <article> + <header> + <TitleTag> + <Link href={`/article/${post.slug}`}> + <a>{post.title}</a> + </Link> + </TitleTag> + </header> + <div dangerouslySetInnerHTML={{ __html: post.content }}></div> + </article> + </li> + ); + }); + + return <ol className={styles.wrapper}>{postsList}</ol>; +}; + +export default PostsList; |
