diff --git a/site/components/Home/Latest.js b/site/components/Home/Latest.js index d12c367..614e604 100644 --- a/site/components/Home/Latest.js +++ b/site/components/Home/Latest.js @@ -1,4 +1,20 @@ +// import { useState } from "react" +import Link from "next/link" +import { YOUTUBE_REGEX } from "../../lib/constants" +import { getYoutube } from "../../utils/getYoutube" + export function Latest({ posts }) { + // const initialValue = 6 + // const [ value, setValue ] = useState(initialValue) + // const initialPosts = posts && posts.slice(0, value) + + // const handleButton = () => { + // setValue(prev => + // initialPosts.length === posts.length + // ? initialValue + // : prev + 3) + // } + return (
- {post.youtube && ["watch", "embed"].some(v => post.youtube.includes(v)) && ( - - Video - )} -
- -{post.title}
-- {post.description && post.description.length > 150 && !!post.image - ? `${post.description.slice(0, 150)} ...` - : post.description - } +
+ {youtube && YOUTUBE_REGEX.test(youtube) ? ( + + Video + ) :
Article
} - + + + {(imageSource) &&{title}
} ++ {description && description.length > 150 + ? `${description.slice(0, imageSource ? 120 : 240)} ...` + : description + } +
+ + +