diff --git a/src/components/blog/Post.js b/src/components/blog/Post.js new file mode 100644 index 00000000..e979d679 --- /dev/null +++ b/src/components/blog/Post.js @@ -0,0 +1,41 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import parse from 'html-react-parser'; + +/** + * Displays a blog post page + * @param {object} props + * { + * title: + * content: + * modified: { + const { title, content, modified, featured_image } = page; + + return ( + <> +

+ {title} +

+

Edited: {modified}

+ featured_img +
{parse(content)}
+ + ); +}; + + +Post.propTypes = { + page: PropTypes.shape({ + title: PropTypes.string.isRequired, + content: PropTypes.string.isRequired, + modified: PropTypes.string, + featured_image: PropTypes.string, + }) +} + +export default Post; diff --git a/src/components/blog/PostList.js b/src/components/blog/PostList.js new file mode 100644 index 00000000..d641d2ce --- /dev/null +++ b/src/components/blog/PostList.js @@ -0,0 +1,41 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import parse from 'html-react-parser'; + +/** + * Displays a list of blog posts with the title and a short excerp from the content. + * @param {object} props + * { + * posts: { + * title: + * excerpt: + * } + * } + * @returns + */ +const PostList = ({ posts }) => { + return ( + <> +

+ {posts.length} posts found +

+ {posts.map((post, index) => ( +
+ + {parse(post.title)} + +

{parse(post.excerpt)}

+
+ ))} + + ); +}; + +PostList.propTypes = { + posts: PropTypes.object.isRequired +} + +export default PostList;