'use client' /** * OnboardingGuideCard (pure presentation + runtime-derived link attrs). * * Three variants: * - `catalog`: rich detail card (hero + author grid) for the public catalog * page. * - `default`: horizontal step-numbered card for "More in {section}" rail. * - `sm`: compact horizontal card for chat-inline rendering. * * Link semantics: the card derives `target`/`rel` from `ChatRuntime.navigation * .decideNewTab` (hub-wired via `HubRuntimeProvider`) and the placeholder * image from the runtime's base API URL (`endpoints.ogPlaceholderUrl`, via * `useEntityCardPlaceholder`). Explicit `target` / `rel` / `placeholderUrl` * props always WIN — chat dispatch and tests can pre-resolve. No runtime * mounted → same-tab + same-origin relative placeholder. */ import React from 'react' import Image from '../../../embed-shims/next-image' import Link from '../../../embed-shims/next-link' import { Clock, ExternalLink, GraduationCap, Play } from 'lucide-react' import { cn } from '../../../utils/cn' import { BlogImagePlaceholder } from './blog-image-placeholder' import { EntityAuthorCard } from './entity-author-card' import { EntityPortraitCard } from './entity-portrait-card' import { formatDurationMMSS } from '../../../utils/format' import type { OnboardingGuide } from '../types/entities/onboarding-guide' import { useEntityCardLink } from './use-entity-card-link' import { useEntityCardPlaceholder } from './use-entity-card-placeholder' import { COMPACT_CARD_OUTER, COMPACT_CARD_IMAGE_SLOT, COMPACT_CARD_SKELETON_IMAGE_SLOT, COMPACT_CARD_SKELETON_OUTER, COMPACT_CARD_TEXT_COL, COMPACT_CARD_TITLE_ROW, COMPACT_CARD_TITLE, COMPACT_CARD_META_ROW_BOX, COMPACT_CARD_SUMMARY, COMPACT_CARD_ROW_FILLER, } from '../utils/compact-card-classes' export interface OnboardingGuideCardProps { guide: OnboardingGuide /** Detail URL resolved by the caller. */ href: string /** When `_blank`, opens in a new tab. Set by chat dispatch via * `computeIsNewTab`. Defaults to same-tab. */ target?: '_blank' rel?: 'noopener noreferrer' targetPlatform?: string | null /** OG placeholder URL used by the catalog + sm variants when no cover. */ placeholderUrl?: string | null size?: 'catalog' | 'default' | 'sm' | 'portrait' /** Portrait density: render the content-type chip. Mixed rails only; single-type rails pass false. Default true. */ showTypeBadge?: boolean | 'default' | 'sm' | 'portrait' className?: string } /** Markdown source → clean one-line preview prose. The guide cards preview * `video_summary || content`, and `content` is raw markdown — without this, * the clamped summary shows literal `**bold**` / `## heading` noise. */ function stripMarkdownPreview(text: string): string { return text .replace(/```[\s\S]*?```/g, ' ') .replace(/^#{1,6}\s+/gm, '') .replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1') .replace(/[*_~`>]/g, '') .replace(/^\s*[-+]\s+/gm, '') .replace(/-{3,}/g, ' ') .replace(/\s+/g, ' ') .trim() // Hard cap — line-clamp is the visual truncation, but a CSS-order // conflict (display utilities vs -webkit-box) once silently killed it // and dumped whole guides into the card. Never ship more than ~2 lines // of source text regardless of CSS. .replace(/^([\s\S]{240})[\s\S]+$/, '$1…') } const HORIZONTAL_SIZE_TOKENS = { default: { padding: 'p-4', step: 'w-8 h-8 text-h6', title: 'text-h5', summaryClamp: 'line-clamp-2', }, } as const export function OnboardingGuideCardSkeleton({ size = 'default' }: { size?: 'catalog' | 'default' | 'sm' }) { if (size === 'catalog') { return (
{stripMarkdownPreview(guide.video_summary || guide.content || '')}