on master help sign in
ecosystem/post: reconstruct permalink from matched post
3fb5bd1Matilde Park
components/ecosystem/Post.js+25−16
@@ -3,25 +3,34 @@ import classnames from "classnames";
3import Link from "next/link";
3import Link from "next/link";
4export default function Post({ post }) {
4export default function Post({ post }) {
5 return ["featured-1", "featured-2", "featured-3"].map((feat) => {
5 return ["featured-1", "featured-2", "featured-3"].map((feat) => {
6+ const childPath =
7+ post[feat] && post[feat]?.matchedPost?.type === "Application"
8+ ? `${post[feat]?.matchedPost.ship}/${post[feat].matchedPost.slug}`
9+ : `${post[feat].matchedPost?.slug}`;
10+ const href = post[feat]?.matchedPost
11+ ? `/${post[feat].matchedPost.type.toLowerCase()}s/${childPath}`
12+ : null;
6 return post?.[feat] ? (
13 return post?.[feat] ? (
7− <div
14+ <Link href={href || "#"}>
15+ <div
8− className="mt-8 mb-24"
16+ className="mt-8 mb-24 cursor-pointer"
9− id={post?.[feat].title.toLowerCase().replace(/ /, "-")}
17+ id={post?.[feat].title.toLowerCase().replace(/ /, "-")}
10− >
18+ >
11− <div className="flex space-x-4 items-center">
19+ <div className="flex space-x-4 items-center">
12− <img
20+ <img
13− className="rounded-xl w-24 object-cover"
21+ className="rounded-xl w-24 object-cover"
14− src={post[feat].image}
22+ src={post[feat].image}
15− />
23+ />
16− <div className="flex flex-col">
24+ <div className="flex flex-col">
17− <h4 className="text-xl pb-1 font-bold">{post?.[feat].title}</h4>
25+ <h4 className="text-xl pb-1 font-bold">{post?.[feat].title}</h4>
18− {badge(post[feat].type)}
26+ {badge(post[feat].type)}
27+ </div>
28+ </div>
29+ <div className="markdown mt-8">
30+ <Markdown.render content={JSON.parse(post[feat].content)} />
19 </div>
31 </div>
20 </div>
32 </div>
21− <div className="markdown mt-8">
33+ </Link>
22− <Markdown.render content={JSON.parse(post[feat].content)} />
23− </div>
24− </div>
25 ) : null;
34 ) : null;
26 });
35 });
27}
36}