about.astro:
---
import FAQ from "@components/FAQ.astro";
---
<FAQ faqs={[
{
question: 'Question 1',
answer: '... <a class="link" href="https://www.example.com/">...</a> ...'
},
{
question: 'Question 2',
answer: 'This is the answer to question 2.'
},
]} />
FAQ.astro:
---
interface Props {
faqs: { question: string, answer: string }[];
}
const { faqs } = Astro.props;
import { Image } from "astro:assets";
import Arrow from '@icons/arrow.svg';
---
<div id="faq">
{faqs.map((item) => (
<div class="question">
<button class="question-toggle">{item.question} <Image src={Arrow} class="question-arrow" alt="Dropdown arrow for answer" width={32} height={32}/></button>
<div class="answer">
<p class="answer-text" set:html={item.answer}></p>
</div>
</div>
))}
</div>
Is there any better way to make this component? I would love to pass a <p> for the answer, since some might have links, but I have to resort to set:html. Thoughts?