mirror of
https://github.com/kremalicious/blog.git
synced 2025-02-14 21:10:25 +01:00
34 lines
852 B
TypeScript
34 lines
852 B
TypeScript
import React from 'react'
|
|
import Changelog from '../../atoms/Changelog'
|
|
import { Post } from '../../../@types/Post'
|
|
import PostToc from './Toc'
|
|
|
|
// Remove lead paragraph from content
|
|
const PostContent = ({ post }: { post: Post }) => {
|
|
const separator = '<!-- more -->'
|
|
const changelog = post.frontmatter.changelog
|
|
|
|
let content = post.html
|
|
|
|
if (post.frontmatter.type === 'post') {
|
|
if (content.includes(separator)) {
|
|
content = content.split(separator)[1]
|
|
} else {
|
|
const lead = content.split('\n')[0]
|
|
content = content.replace(lead, '')
|
|
}
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{post.frontmatter.toc && (
|
|
<PostToc tableOfContents={post.tableOfContents} />
|
|
)}
|
|
<div dangerouslySetInnerHTML={{ __html: content }} />
|
|
{changelog && <Changelog repo={changelog} />}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default PostContent
|