|
| 1 | +--- |
| 2 | +import { PortableText } from "astro-portabletext"; |
| 3 | +import { urlForImage } from "@/utils/sanity"; |
| 4 | +import ContentCard from "./ContentCard.astro"; |
| 5 | +
|
| 6 | +interface Props { |
| 7 | + person: any; |
| 8 | + type: "author" | "guest" | "sponsor"; |
| 9 | +} |
| 10 | +
|
| 11 | +const { person, type } = Astro.props; |
| 12 | +
|
| 13 | +const coverUrl = person.coverImage |
| 14 | + ? urlForImage(person.coverImage).width(400).height(400).format("webp").url() |
| 15 | + : null; |
| 16 | +
|
| 17 | +function getHostname(url: string): string { |
| 18 | + try { return new URL(url).hostname; } |
| 19 | + catch { return url; } |
| 20 | +} |
| 21 | +--- |
| 22 | + |
| 23 | +<div class="flex flex-col md:flex-row gap-8 mb-12"> |
| 24 | + {coverUrl && ( |
| 25 | + <img |
| 26 | + src={coverUrl} |
| 27 | + alt={person.title} |
| 28 | + width={400} |
| 29 | + height={400} |
| 30 | + class="w-48 h-48 rounded-full object-cover flex-shrink-0" |
| 31 | + /> |
| 32 | + )} |
| 33 | + <div> |
| 34 | + <h1 class="text-4xl font-bold mb-4">{person.title}</h1> |
| 35 | + {person.excerpt && ( |
| 36 | + <p class="text-gray-600 text-lg mb-4">{person.excerpt}</p> |
| 37 | + )} |
| 38 | + {person.socials && ( |
| 39 | + <div class="flex flex-wrap gap-3"> |
| 40 | + {person.socials.twitter && ( |
| 41 | + <a href={`https://twitter.com/${person.socials.twitter}`} target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline"> |
| 42 | + Twitter |
| 43 | + </a> |
| 44 | + )} |
| 45 | + {person.socials.github && ( |
| 46 | + <a href={`https://github.com/${person.socials.github}`} target="_blank" rel="noopener noreferrer" class="text-gray-700 hover:underline"> |
| 47 | + GitHub |
| 48 | + </a> |
| 49 | + )} |
| 50 | + {person.socials.linkedin && ( |
| 51 | + <a href={person.socials.linkedin} target="_blank" rel="noopener noreferrer" class="text-blue-700 hover:underline"> |
| 52 | + LinkedIn |
| 53 | + </a> |
| 54 | + )} |
| 55 | + </div> |
| 56 | + )} |
| 57 | + {person.websites && person.websites.length > 0 && ( |
| 58 | + <div class="flex flex-wrap gap-3 mt-2"> |
| 59 | + {person.websites.map((site: string) => ( |
| 60 | + <a href={site} target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:underline text-sm"> |
| 61 | + {getHostname(site)} |
| 62 | + </a> |
| 63 | + ))} |
| 64 | + </div> |
| 65 | + )} |
| 66 | + </div> |
| 67 | +</div> |
| 68 | + |
| 69 | +{person.content && ( |
| 70 | + <div class="prose prose-lg max-w-none mb-12"> |
| 71 | + <PortableText value={person.content} /> |
| 72 | + </div> |
| 73 | +)} |
| 74 | + |
| 75 | +{person.related && ( |
| 76 | + <> |
| 77 | + {person.related.podcast && person.related.podcast.length > 0 && ( |
| 78 | + <section class="mb-12"> |
| 79 | + <h2 class="text-2xl font-bold mb-6">Related Podcasts</h2> |
| 80 | + <div class="grid gap-6 md:grid-cols-2 lg:grid-cols-4"> |
| 81 | + {person.related.podcast.map((p: any) => ( |
| 82 | + <ContentCard |
| 83 | + title={p.title} |
| 84 | + slug={`/podcast/${p.slug}`} |
| 85 | + coverImage={p.coverImage} |
| 86 | + excerpt={p.excerpt} |
| 87 | + date={p.date} |
| 88 | + /> |
| 89 | + ))} |
| 90 | + </div> |
| 91 | + </section> |
| 92 | + )} |
| 93 | + |
| 94 | + {person.related.post && person.related.post.length > 0 && ( |
| 95 | + <section class="mb-12"> |
| 96 | + <h2 class="text-2xl font-bold mb-6">Related Posts</h2> |
| 97 | + <div class="grid gap-6 md:grid-cols-2 lg:grid-cols-4"> |
| 98 | + {person.related.post.map((p: any) => ( |
| 99 | + <ContentCard |
| 100 | + title={p.title} |
| 101 | + slug={`/post/${p.slug}`} |
| 102 | + coverImage={p.coverImage} |
| 103 | + excerpt={p.excerpt} |
| 104 | + date={p.date} |
| 105 | + /> |
| 106 | + ))} |
| 107 | + </div> |
| 108 | + </section> |
| 109 | + )} |
| 110 | + </> |
| 111 | +)} |
0 commit comments