diff --git a/components/BlogPost.tsx b/components/BlogPost.tsx new file mode 100644 index 0000000..f4090ec --- /dev/null +++ b/components/BlogPost.tsx @@ -0,0 +1,53 @@ +import Head from 'next/head'; +import React, { useEffect } from 'react'; +import { useDispatch } from 'react-redux'; + +import { PageType, setPageType, setPostTitle } from '../state/navigation'; +import { IPost } from '../types/cms'; +import { generateTitle } from '../utils/metadata'; + +import { Article } from '../components/article/Article'; + +// Parallax on bg as mouse moves +export default function BlogPost({ post, url }: { post: IPost; url: string }) { + const dispatch = useDispatch(); + const pageTitle = generateTitle(post?.title); + const imageURL = post?.featureImage?.imageUrl; + + useEffect(() => { + if (post) { + dispatch(setPageType(PageType.POST)); + dispatch(setPostTitle(post.title)); + } + }, []); + + return ( + <> +
+- {children} -
- ); + if (isShortcode) { + return renderShortcode(plaintext); + } else { + let hasImage = false; + Children.map(children, (child: any) => { + if (child.type === 'figure') { + hasImage = true; + return; + } + }); + if (hasImage) { + return ( + + {children} + + ); + } + return ( ++ {children} +
+ ); + } }, [BLOCKS.HEADING_1]: (node, children) => (- {tagHasPosts - ? 'Tag Results:' - : 'There are no posts with the tag'} -
-+ {tagHasPosts + ? 'Tag Results:' + : 'There are no posts with the tag:'} +
+