Skip to content

Commit 71181e4

Browse files
committed
feat: add faq to pricing page
1 parent f22b2ea commit 71181e4

File tree

6 files changed

+125
-2
lines changed

6 files changed

+125
-2
lines changed

docs/src/content.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { glob } from "astro/loaders";
22
import { z, defineCollection } from "astro:content";
33

44
import { pricingCollection } from "./types/pages.collection";
5-
import {comparePlansSectionCollection, pricingSectionCollection, statisticsSectionCollection } from "./types/sections.collections";
5+
import {comparePlansSectionCollection, faqSectionCollection, pricingSectionCollection, statisticsSectionCollection } from "./types/sections.collections";
66

77

88

@@ -36,4 +36,4 @@ const feature = defineCollection({
3636
}),
3737
});
3838

39-
export const collections = { feature, pricing: pricingCollection, comparePlansSectionCollection, pricingSectionCollection, statisticsSectionCollection };
39+
export const collections = { feature, pricing: pricingCollection, comparePlansSectionCollection, faqSectionCollection, pricingSectionCollection, statisticsSectionCollection };

docs/src/content/sections/faq.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
enable: true
3+
title: "Frequently Asked <em>Questions</em>"
4+
list:
5+
- enable: true
6+
question: "What is included in the trial plan?"
7+
answer: "Trial plan include everything available for the Teams plan."
8+
- enable: true
9+
question: "What happens when my trials is over?"
10+
answer: "You will have the option to convert to a paying plan or you'll loose access to RocketSim Pro features and team build insights."
11+
- enable: true
12+
question: "Can I cancel, upgrade, or downgrade anytime?"
13+
answer: "Yes. You can cancel, upgrade, or downgrade your plan via your subscription settings within the web app. All cancellations and downgrades will take place at the end of your plan cycle, while upgrades will take place immediately."
14+
---
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
import { markdownify } from "@/lib/utils/textConverter";
3+
import Accordion from "@/shortcodes/Accordion";
4+
import type { CollectionEntry } from "astro:content";
5+
import { getEntry } from "astro:content";
6+
7+
const sectionData = (await getEntry("faqSectionCollection", "faq")) as CollectionEntry<"faqSectionCollection">;
8+
const { title, list } = sectionData.data;
9+
---
10+
11+
<section class="section" id="faq_section">
12+
<div class="container">
13+
<div class="section-container gap-10">
14+
<div class="section-intro text-center">
15+
<h2 set:html={markdownify(title)} class="title hasEmphasize" data-aos="fade-up-sm" data-aos-delay="0" />
16+
</div>
17+
<div class="section-content space-y-5">
18+
{
19+
list.map((item, index) => (
20+
<div data-aos="fade-up-sm" data-aos-delay={100 * index}>
21+
<Accordion client:load title={item.question}>
22+
<div set:html={markdownify(item.answer)} />
23+
</Accordion>
24+
</div>
25+
))
26+
}
27+
</div>
28+
</div>
29+
</div>
30+
</section>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React, { useState } from "react";
2+
3+
const Accordion = ({
4+
title,
5+
children,
6+
className,
7+
}: {
8+
title: string;
9+
children: React.ReactNode;
10+
className?: string;
11+
}) => {
12+
const [show, setShow] = useState(false);
13+
const contentRef = React.useRef<HTMLDivElement>(null);
14+
const [height, setHeight] = React.useState(show ? "auto" : "0px");
15+
16+
React.useEffect(() => {
17+
if (show) {
18+
setHeight(`${contentRef.current?.scrollHeight}px`);
19+
} else {
20+
setHeight("0px");
21+
}
22+
}, [show]);
23+
24+
return (
25+
<div className={`accordion ${className}`}>
26+
<button className="accordion-header" onClick={() => setShow(!show)}>
27+
{title}
28+
29+
<div className="inline-block accordion-icon">
30+
<svg
31+
className={` transition-transform duration-500 ${show ? "rotate-180" : ""}`}
32+
xmlns="http://www.w3.org/2000/svg"
33+
width="24"
34+
height="24"
35+
viewBox="0 0 24 24"
36+
fill="none"
37+
stroke="currentColor"
38+
strokeWidth="1.5"
39+
strokeLinecap="round"
40+
strokeLinejoin="round"
41+
>
42+
<line
43+
x1="12"
44+
y1="5"
45+
x2="12"
46+
y2="19"
47+
className={`transition-opacity duration-500 ${show ? "opacity-0" : "opacity-100"}`}
48+
></line>
49+
<line x1="5" y1="12" x2="19" y2="12"></line>
50+
</svg>
51+
</div>
52+
</button>
53+
<div ref={contentRef} style={{ height, overflow: "hidden", transition: "height 0.5s ease" }}>
54+
{show && <div className={show ? "accordion-content [&_*]:text-base [&_*]:m-0" : "mt-0"}>{children}</div>}
55+
</div>
56+
</div>
57+
);
58+
};
59+
60+
export default Accordion;

docs/src/pages/pricing.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import PageHeader from "@/partials/PageHeader.astro";
66
import PricingSection from "@/partials/PricingSection.astro";
77
import ComparePlans from "@/partials/ComparePlans.astro";
88
import Statistics from "@/partials/Statistics.astro";
9+
import FaqSection from "@/partials/FaqSection.astro";
910
1011
const pageIndex = await getEntry("pricing", "-index");
1112
if (!pageIndex) return null;
@@ -19,4 +20,5 @@ const { hero, title, meta_title, description } = pageIndex.data;
1920
</div>
2021
<ComparePlans />
2122
<Statistics isFluid="true" />
23+
<FaqSection />
2224
</Base>

docs/src/types/sections.collections.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ export const comparePlansSectionCollection = defineCollection({
3232
}),
3333
});
3434

35+
// FAQ Section collection schema
36+
export const faqSectionCollection = defineCollection({
37+
loader: glob({
38+
pattern: "faq.{md,mdx}",
39+
base: "src/content/sections",
40+
}),
41+
schema: z.object({
42+
title: z.string(),
43+
list: z.array(
44+
z.object({
45+
question: z.string(),
46+
answer: z.string(),
47+
})
48+
),
49+
}),
50+
});
51+
3552
// Pricing Section collection schema
3653
export const pricingSectionCollection = defineCollection({
3754
loader: glob({

0 commit comments

Comments
 (0)