diff --git a/src/components/FeatureTable.astro b/src/components/FeatureTable.astro index 3739dafea623b4..a3c61e878227ba 100644 --- a/src/components/FeatureTable.astro +++ b/src/components/FeatureTable.astro @@ -4,6 +4,12 @@ import { indexPlans } from "~/util/plans"; import { marked } from "marked"; import GlossaryTooltip from "~/components/GlossaryTooltip.astro"; +const markdown = (content: any) => { + if (typeof content !== "string") return content; + + return marked.parse(content); +}; + type Props = z.infer; const props = z @@ -17,30 +23,29 @@ const { id } = props.parse(Astro.props); // TODO: improve product features types const plan = (await indexPlans(id)) as any; -// @ts-ignore types not implemented for plans JSON -const properties = plan.properties; +const features: any[] = Object.values(plan.properties); -const markdown = (content: any) => { - if (typeof content !== "string") return content; - - return marked.parse(content); -}; +const hasFree = features.some((x) => x.free); +const hasPro = features.some((x) => x.pro); +const hasBiz = features.some((x) => x.biz); +const hasEnt = features.some((x) => x.ent); +const hasEntPlus = features.some((x) => x.ent_plus); --- - - - - - {plan.ent_plus && } + {hasFree && } + {hasPro && } + {hasBiz && } + {hasEnt && } + {hasEntPlus && } { - Object.entries(properties).map(([_, v]: [string, any]) => { + features.map((feature) => { const renderTitle = (title: string) => { const placeholder = "[[GLOSSARY_TOOLTIP_SNIPPETS_SUBREQUEST]]"; @@ -67,12 +72,12 @@ const markdown = (content: any) => { return ( - ); })
FreeProBusinessEnterprise{plan.ent_plus}FreeProBusinessEnterprise{plan.ent_plus}
- - - - - {plan.ent_plus && } + + {hasFree && } + {hasPro && } + {hasBiz && } + {hasEnt && } + {hasEntPlus && }