11import { CREDIT_TIERS } from '@/lib/billing/constants'
2- import type { CompetitorProfile , Fact , Prose } from '@/lib/compare/data'
2+ import type { ComparisonQuestion , CompetitorProfile , Fact , Prose } from '@/lib/compare/data'
33import { simProfile } from '@/lib/compare/data'
44import { toSiteUrl } from '@/lib/core/utils/urls'
55import { getAllCustomerStoryMeta , getCustomerStorySource } from '@/lib/customers/registry'
@@ -13,7 +13,7 @@ import {
1313 ALL_COMPETITORS ,
1414 buildBottomLine ,
1515 getLatestVerifiedDate ,
16- getQuestionSections ,
16+ getQuestionSectionGroups ,
1717 SIM_LATEST_VERIFIED ,
1818} from '@/app/(landing)/comparisons/utils'
1919import { PLATFORM_MENU } from '@/app/(landing)/components/navbar/components/nav-menu-chip'
@@ -81,8 +81,13 @@ function isoDate(date: Date): string {
8181}
8282
8383/** The key facts of one `/comparisons/{id}` page as markdown, from the same profile data. */
84+ function questionMarkdown ( { question, answer } : ComparisonQuestion ) : string {
85+ return `**${ question } **\n\n${ proseToMarkdown ( answer ) } `
86+ }
87+
8488function comparisonMarkdown ( competitor : CompetitorProfile ) : string {
8589 const verdict = buildBottomLine ( competitor )
90+ const questions = getQuestionSectionGroups ( competitor )
8691 const verified = new Date (
8792 Math . max ( SIM_LATEST_VERIFIED . getTime ( ) , getLatestVerifiedDate ( competitor ) . getTime ( ) )
8893 )
@@ -100,9 +105,7 @@ function comparisonMarkdown(competitor: CompetitorProfile): string {
100105 `URL: ${ toSiteUrl ( `/comparisons/${ competitor . id } ` ) } · Facts last verified ${ isoDate ( verified ) } ` ,
101106 `${ competitor . name } : ${ competitor . oneLiner } ` ,
102107 competitor . leadAnswer && ! competitor . leadQuestion ? proseToMarkdown ( competitor . leadAnswer ) : '' ,
103- ...getQuestionSections ( competitor ) . map (
104- ( { question, answer } ) => `**${ question } **\n\n${ proseToMarkdown ( answer ) } `
105- ) ,
108+ ...questions . opening . map ( questionMarkdown ) ,
106109 competitor . glance
107110 ? [
108111 `| Decision point | Sim | ${ competitor . name } |` ,
@@ -113,6 +116,7 @@ function comparisonMarkdown(competitor: CompetitorProfile): string {
113116 ) ,
114117 ] . join ( '\n' )
115118 : '' ,
119+ ...questions . glance . map ( questionMarkdown ) ,
116120 `- ${ verdict . chooseSim } \n- ${ verdict . chooseCompetitor } ` ,
117121 competitor . standoutFeatures . length > 0
118122 ? `Standout features of ${ competitor . name } :\n\n${ competitor . standoutFeatures . map ( ( f ) => `- ${ f . title } : ${ f . description } ` ) . join ( '\n' ) } `
@@ -121,6 +125,7 @@ function comparisonMarkdown(competitor: CompetitorProfile): string {
121125 ? `Documented limitations of ${ competitor . name } :\n\n${ competitor . limitations . map ( ( l ) => `- ${ l . title } : ${ l . description } ` ) . join ( '\n' ) } `
122126 : '' ,
123127 [ `| Feature | Sim | ${ competitor . name } |` , '| --- | --- | --- |' , ...rows ] . join ( '\n' ) ,
128+ ...questions . closing . map ( questionMarkdown ) ,
124129 ]
125130 . filter ( Boolean )
126131 . join ( '\n\n' )
0 commit comments