Skip to content

Commit

Permalink
Fix Snippets markdown in feature table (#16130)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Cano <[email protected]>
  • Loading branch information
kodster28 and nikitacano authored Aug 14, 2024
1 parent 1fae4e7 commit 5e8662d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
34 changes: 27 additions & 7 deletions src/components/FeatureTable.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from "astro:content";
import { Card } from "~/components";
import { indexPlans } from "~/util/plans";
import { marked } from "marked";
import { GlossaryTooltip } from "~/components";
type Props = z.infer<typeof props>;
Expand Down Expand Up @@ -31,16 +32,35 @@ const properties = plan.properties;
</tr>
</thead>
<tbody>
{
Object.entries(properties).map(([k, v]) => {
const markdown = (content) => {
if (typeof content !== "string") return content;
{Object.entries(properties).map(([k, v]) => {
const renderTitle = (title) => {
const placeholder = "[[GLOSSARY_TOOLTIP_SNIPPETS_SUBREQUEST]]";

return marked.parse(content);
};
if (title.includes(placeholder)) {
const [beforePlaceholder, afterPlaceholder] = title.split(placeholder);

return (
<>
{beforePlaceholder}
<GlossaryTooltip term="Snippets subrequest" prepend="A subrequest is ">
subrequests
</GlossaryTooltip>
{afterPlaceholder}
</>
);
}

return title;
};

const markdown = (content) => {
if (typeof content !== "string") return content;
return marked.parse(content);
};

return (
<tr>
<td set:html={markdown(v.title)} />
<td>{renderTitle(v.title)}</td>
<td set:html={markdown(v.free)} />
<td set:html={markdown(v.pro)} />
<td set:html={markdown(v.biz)} />
Expand Down
2 changes: 1 addition & 1 deletion src/content/plans/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@
"ent": 50
},
"subrequests": {
"title": "Number of {{<glossary-tooltip term_id=\"Snippets subrequest\" prepend=\"A subrequest is \">}}subrequests{{</glossary-tooltip>}}",
"title": "Number of [[GLOSSARY_TOOLTIP_SNIPPETS_SUBREQUEST]]",
"free": 0,
"pro": 2,
"biz": 3,
Expand Down

0 comments on commit 5e8662d

Please sign in to comment.