/* ═══════════════════════════════════════════════════════════════ COMMUNITY BLOG The Community page's blog section (Admin → Pages → Community blog section). Two halves, each pinned first and then newest, as routes/blog.js decides: our posts cards for our own /blog/:id pages community posts featured cards (pinned by hand, or the newest from the listed feeds), drawn by FeaturedCards, with a button to the Substack The section's heading and blurb come from the same record; the page reads them through the same cached request (Community.tsx). A half with nothing in it isn't drawn. ═══════════════════════════════════════════════════════════════ */ import { Link } from 'react-router-dom' import FeaturedCards from '../../components/FeaturedCards.tsx' import PlatformIcon from '../../components/PlatformIcon.tsx' import { blogHref } from '../../lib/hrefs.ts' import { mediaUrl } from '../../lib/media.ts' import { preview } from '../../lib/text.ts' import { postDate, useCommunityBlog, type BlogPostSummary } from '../../lib/useBlog.ts' import HomeLink from './home/HomeLink.tsx' import { accentText, BRAND } from '../../lib/color.ts' import { useSmallImage } from '../../lib/useSmallImage.ts' /* Headings for a half the admin didn't title. */ const DEFAULTS = { internal: 'From NGU', external: 'From our community', externalLabel: 'Read more on Substack', } const EXCERPT_CHARS = 180 /* One post as a card; person pages list their posts with it too. */ export function PostCard({ post, accent }: { post: BlogPostSummary; accent: string }) { const cover = useSmallImage(mediaUrl(post.cover_image)) const date = postDate(post.published_on) const authors = post.authors.map((author) => author.name).join(', ') return (
  • {!cover.failed ? ( ) : (
    )}
    {(date || post.tags.length > 0) && (

    {[date, ...post.tags].filter(Boolean).join(' · ')}

    )}

    {post.title}

    {post.excerpt && (

    {preview(post.excerpt, EXCERPT_CHARS)}

    )} {authors &&

    By {authors}

    }
  • ) } function Subheading({ children, accent }: { children: string; accent: string }) { return (

    {children}

    ) } export default function CommunityBlog({ accent = BRAND }: { accent?: string }) { const { data: blog, loading, error, reload } = useCommunityBlog() if (!blog) { return (
    {loading ? ( 'Loading…' ) : ( <> Couldn’t load the blog. {error}{' '} )}
    ) } const { internal, external } = blog const hasInternal = internal.posts.length > 0 const hasExternal = external.cards.length > 0 || Boolean(external.url) if (!hasInternal && !hasExternal) { return

    · Posts coming soon ·

    } return (
    {hasInternal && (
    {internal.title || DEFAULTS.internal}
    )} {hasExternal && (
    {external.title || DEFAULTS.external} {external.url && ( {external.label || DEFAULTS.externalLabel} )}
    {external.cards.length > 0 && (
    )}
    )}
    ) }