|
| 1 | +import { getArticleBySlug, getAllArticles } from '@/lib/markdown' |
| 2 | +import { AppSidebar } from '@/components/app-sidebar' |
| 3 | +import { TracingBeam } from '@/components/ui/tracing-beam' |
| 4 | +import { cn } from '@/lib/utils' |
| 5 | +import { notFound } from 'next/navigation' |
| 6 | +import Link from 'next/link' |
| 7 | +import { ArrowLeft, Clock, Tag, User, Calendar, Share2 } from 'lucide-react' |
| 8 | +import { Toc } from '@/components/ui/toc' |
| 9 | + |
| 10 | +interface ArticlePageProps { |
| 11 | + params: { |
| 12 | + slug: string |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +export async function generateStaticParams() { |
| 17 | + const articles = await getAllArticles() |
| 18 | + return articles.map((article) => ({ |
| 19 | + slug: article.slug, |
| 20 | + })) |
| 21 | +} |
| 22 | + |
| 23 | +// TOC moved to client component '@/components/ui/toc' |
| 24 | + |
| 25 | +export default async function ArticlePage({ params }: ArticlePageProps) { |
| 26 | + const article = await getArticleBySlug(params.slug) |
| 27 | + |
| 28 | + if (!article) { |
| 29 | + notFound() |
| 30 | + } |
| 31 | + |
| 32 | + const readingTime = Math.ceil(article.content.replace(/<[^>]*>/g, '').split(' ').length / 200) |
| 33 | + // Remove only the inline "Continue the Exploration..." section (keep trailing keywords/source) |
| 34 | + const withoutInlineContinue = article.content.replace( |
| 35 | + /<h[2-3][^>]*>\s*Continue the Exploration\.\.\.\s*<\/h[2-3]>[\s\S]*?(?=<hr\b|<h[1-6]|$)/i, |
| 36 | + '', |
| 37 | + ) |
| 38 | + // Split after the opening paragraph/question: find first section heading (h2/h3) |
| 39 | + const firstSection = /<h[2-3][^>]*>/i.exec(withoutInlineContinue) |
| 40 | + const introHtml = firstSection ? withoutInlineContinue.slice(0, firstSection.index) : '' |
| 41 | + const contentAfterIntro = firstSection ? withoutInlineContinue.slice(firstSection.index) : withoutInlineContinue |
| 42 | + |
| 43 | + return ( |
| 44 | + <div className={cn("flex flex-col md:flex-row bg-gray-100 dark:bg-neutral-800 w-full flex-1 mx-auto border border-neutral-200 dark:border-neutral-700 overflow-visible md:overflow-hidden min-h-screen md:h-screen")}> |
| 45 | + <AppSidebar /> |
| 46 | + <div className="flex flex-1"> |
| 47 | + <div id="scroll-container" className="p-2 md:p-10 rounded-tl-2xl border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-900 flex flex-col gap-2 flex-1 w-full md:h-full h-auto md:overflow-y-auto overflow-visible"> |
| 48 | + <div className="flex gap-8 max-w-7xl mx-auto w-full"> |
| 49 | + {/* Main Content */} |
| 50 | + <div className="flex-1 min-w-0"> |
| 51 | + <TracingBeam className="px-6"> |
| 52 | + <div className="max-w-2xl mx-auto antialiased pt-4 relative"> |
| 53 | + {/* Back Button */} |
| 54 | + <Link |
| 55 | + href="/atlas" |
| 56 | + className="inline-flex items-center gap-2 text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 mb-8 group" |
| 57 | + > |
| 58 | + <ArrowLeft className="w-4 h-4 group-hover:-translate-x-1 transition-transform" /> |
| 59 | + Back to Atlas |
| 60 | + </Link> |
| 61 | + |
| 62 | + {/* Article Header */} |
| 63 | + <header className="mb-12"> |
| 64 | + |
| 65 | + <h1 className="text-4xl md:text-5xl font-bold text-neutral-900 dark:text-neutral-100 mb-6 leading-tight"> |
| 66 | + {article.frontmatter.title} |
| 67 | + </h1> |
| 68 | + |
| 69 | + {article.frontmatter.summary && ( |
| 70 | + <p className="text-xl text-neutral-700 dark:text-neutral-300 leading-relaxed mb-8 font-medium"> |
| 71 | + {article.frontmatter.summary} |
| 72 | + </p> |
| 73 | + )} |
| 74 | + |
| 75 | + {/* Meta Information */} |
| 76 | + <div className="flex flex-wrap items-center gap-6 text-sm text-neutral-600 dark:text-neutral-400 mb-8"> |
| 77 | + {article.frontmatter.author && ( |
| 78 | + <div className="flex items-center gap-2"> |
| 79 | + <User className="w-4 h-4" /> |
| 80 | + <span>{article.frontmatter.author}</span> |
| 81 | + </div> |
| 82 | + )} |
| 83 | + |
| 84 | + <div className="flex items-center gap-2"> |
| 85 | + <Calendar className="w-4 h-4" /> |
| 86 | + <time dateTime={article.frontmatter.date}> |
| 87 | + {new Date(article.frontmatter.date).toLocaleDateString('en-US', { |
| 88 | + year: 'numeric', |
| 89 | + month: 'long', |
| 90 | + day: 'numeric' |
| 91 | + })} |
| 92 | + </time> |
| 93 | + </div> |
| 94 | + |
| 95 | + <div className="flex items-center gap-2"> |
| 96 | + <Clock className="w-4 h-4" /> |
| 97 | + <span>{readingTime} min read</span> |
| 98 | + </div> |
| 99 | + |
| 100 | + <button className="flex items-center gap-2 hover:text-neutral-900 dark:hover:text-neutral-100 transition-colors"> |
| 101 | + <Share2 className="w-4 h-4" /> |
| 102 | + <span>Share</span> |
| 103 | + </button> |
| 104 | + </div> |
| 105 | + |
| 106 | + {/* Tags */} |
| 107 | + {article.frontmatter.tags && article.frontmatter.tags.length > 0 && ( |
| 108 | + <div className="flex flex-wrap gap-2 mb-8"> |
| 109 | + {article.frontmatter.tags.map((tag) => ( |
| 110 | + <span |
| 111 | + key={tag} |
| 112 | + className="inline-flex items-center gap-1 px-3 py-1 bg-neutral-100 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300 rounded-full text-sm" |
| 113 | + > |
| 114 | + <Tag className="w-3 h-3" /> |
| 115 | + {tag} |
| 116 | + </span> |
| 117 | + ))} |
| 118 | + </div> |
| 119 | + )} |
| 120 | + </header> |
| 121 | + |
| 122 | + {/* Monologue Content */} |
| 123 | + {/* Intro paragraph/question */} |
| 124 | + {introHtml && ( |
| 125 | + <article |
| 126 | + className="prose prose-neutral dark:prose-invert prose-lg max-w-prose prose-p:leading-relaxed prose-p:text-neutral-700 dark:prose-p:text-neutral-300" |
| 127 | + dangerouslySetInnerHTML={{ __html: introHtml }} |
| 128 | + /> |
| 129 | + )} |
| 130 | + |
| 131 | + {/* Decorative separator under the intro */} |
| 132 | + {introHtml && ( |
| 133 | + <div className="my-8 flex items-center"> |
| 134 | + <div className="h-px flex-1 bg-gradient-to-r from-transparent via-blue-300 to-transparent dark:via-blue-700" /> |
| 135 | + <span className="mx-3 text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400">Deep Dive</span> |
| 136 | + <div className="h-px flex-1 bg-gradient-to-r from-transparent via-purple-300 to-transparent dark:via-purple-700" /> |
| 137 | + </div> |
| 138 | + )} |
| 139 | + |
| 140 | + {/* Main content */} |
| 141 | + <article id="article-root" |
| 142 | + className="prose prose-neutral dark:prose-invert prose-lg max-w-prose prose-headings:scroll-mt-8 prose-headings:font-bold prose-h1:text-3xl prose-h1:mb-8 prose-h2:text-2xl prose-h2:mt-12 prose-h2:mb-6 prose-h3:text-xl prose-h3:mt-8 prose-h3:mb-4 prose-p:leading-relaxed prose-p:text-neutral-700 dark:prose-p:text-neutral-300 prose-blockquote:border-l-4 prose-blockquote:border-blue-500 prose-blockquote:bg-blue-50 dark:prose-blockquote:bg-blue-950/30 prose-blockquote:py-2 prose-blockquote:px-4 prose-strong:text-neutral-900 dark:prose-strong:text-neutral-100 prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline" |
| 143 | + dangerouslySetInnerHTML={{ __html: contentAfterIntro }} |
| 144 | + /> |
| 145 | + |
| 146 | + {/* Continue Exploration Section (bottom card) */} |
| 147 | + <div className="mt-16 p-6 bg-gradient-to-r from-blue-50 to-purple-50 dark:from-blue-950/30 dark:to-purple-950/30 rounded-xl border border-blue-200 dark:border-blue-800"> |
| 148 | + <h3 className="text-lg font-semibold text-neutral-900 dark:text-neutral-100 mb-4"> |
| 149 | + Continue the Exploration... |
| 150 | + </h3> |
| 151 | + <div className="grid grid-cols-1 md:grid-cols-2 gap-3"> |
| 152 | + <Link href="#" className="p-3 bg-white dark:bg-neutral-800 rounded-lg border border-neutral-200 dark:border-neutral-700 hover:border-blue-300 dark:hover:border-blue-600 transition-colors"> |
| 153 | + <span className="text-sm font-medium text-neutral-900 dark:text-neutral-100">Collaborative Reality Mathematics</span> |
| 154 | + </Link> |
| 155 | + <Link href="#" className="p-3 bg-white dark:bg-neutral-800 rounded-lg border border-neutral-200 dark:border-neutral-700 hover:border-blue-300 dark:hover:border-blue-600 transition-colors"> |
| 156 | + <span className="text-sm font-medium text-neutral-900 dark:text-neutral-100">Identity Fractals at the Mortality Boundary</span> |
| 157 | + </Link> |
| 158 | + </div> |
| 159 | + </div> |
| 160 | + |
| 161 | + {/* Source Information */} |
| 162 | + {article.frontmatter.source_run_id && ( |
| 163 | + <div className="mt-8 pt-8 border-t border-neutral-200 dark:border-neutral-700"> |
| 164 | + <div className="text-xs text-neutral-500 dark:text-neutral-500"> |
| 165 | + <strong>Keywords:</strong> {article.frontmatter.tags?.join(', ')} |
| 166 | + {article.frontmatter.source_files && ( |
| 167 | + <div className="mt-1"> |
| 168 | + <strong>Source:</strong> Adapted from Trinity dialogue series, Run {article.frontmatter.source_run_id} |
| 169 | + </div> |
| 170 | + )} |
| 171 | + </div> |
| 172 | + </div> |
| 173 | + )} |
| 174 | + </div> |
| 175 | + </TracingBeam> |
| 176 | + </div> |
| 177 | + |
| 178 | + {/* Right Sidebar - TOC with highlight & LLM Export */} |
| 179 | + <div className="hidden xl:block"> |
| 180 | + <Toc contentHtml={contentAfterIntro} /> |
| 181 | + </div> |
| 182 | + </div> |
| 183 | + </div> |
| 184 | + </div> |
| 185 | + </div> |
| 186 | + ) |
| 187 | +} |
0 commit comments