2018-11-21 23:39:09 +01:00
|
|
|
import React, { Fragment } from 'react'
|
2018-07-22 04:27:37 +02:00
|
|
|
import PropTypes from 'prop-types'
|
2018-11-21 23:39:09 +01:00
|
|
|
import Changelog from '../atoms/Changelog'
|
2018-07-22 04:27:37 +02:00
|
|
|
|
|
|
|
// Remove lead paragraph from content
|
|
|
|
const PostContent = ({ post }) => {
|
|
|
|
const separator = '<!-- more -->'
|
2018-11-21 23:39:09 +01:00
|
|
|
const changelog = post.frontmatter.changelog
|
2018-07-22 04:27:37 +02:00
|
|
|
|
2018-11-21 23:39:09 +01:00
|
|
|
let content = post.html
|
2018-07-22 04:27:37 +02:00
|
|
|
|
|
|
|
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, '')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-21 23:39:09 +01:00
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<div dangerouslySetInnerHTML={{ __html: content }} />
|
|
|
|
{changelog && <Changelog repo={changelog} />}
|
|
|
|
</Fragment>
|
|
|
|
)
|
2018-07-22 04:27:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PostContent.propTypes = {
|
|
|
|
post: PropTypes.object
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PostContent
|