Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat(content): add faq component

Marc Seitza20a627db857
diff --git a/components/mdx/components/faq.tsx b/components/mdx/components/faq.tsx
new file mode 100644
index 00000000..5360b131
--- /dev/null
+++ b/components/mdx/components/faq.tsx
@@ -0,0 +1,34 @@
+import {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
+} from "@/components/ui/accordion";
+
+type Row = {
+ question: string;
+ answer: string;
+};
+
+type FaqProps = {
+ rows: Row[];
+};
+
+export const Faq: React.FC<FaqProps> = ({ rows }) => {
+ return (
+ <Accordion type="single" collapsible className="not-prose space-y-4">
+ {rows.map((row, index) => (
+ <AccordionItem key={index} value={row.question}>
+ <AccordionTrigger className="flex w-full items-start justify-between text-left text-gray-800 hover:no-underline">
+ <span className="text-balance font-medium leading-7">
+ {row.question}
+ </span>
+ </AccordionTrigger>
+ <AccordionContent className="mt-2 pr-12">
+ <p className="text-balance leading-7 text-gray-500">{row.answer}</p>
+ </AccordionContent>
+ </AccordionItem>
+ ))}
+ </Accordion>
+ );
+};
diff --git a/components/mdx/components/index.tsx b/components/mdx/components/index.tsx
index 3dd7f39d..c77a4288 100644
--- a/components/mdx/components/index.tsx
+++ b/components/mdx/components/index.tsx
@@ -5,6 +5,7 @@ import { Code } from "bright";
import { MDXComponents } from "mdx/types";
import { Button } from "@/components/ui/button";
+import Faq from "@/components/web/faq";
import { cn } from "@/lib/utils";
@@ -92,5 +93,10 @@ export const mdxComponents: MDXComponents = {
return <Table columns={columns} rows={rows} {...props} />;
},
+ Faq: ({ rows, ...props }) => {
+ if (!rows || rows.length === 0) return null;
+
+ return <Faq rows={rows} {...props} />;
+ },
// any other components you want to use in your markdown
};