mirror of
https://github.com/meshtastic/meshtastic.git
synced 2025-02-02 08:42:11 -08:00
standalone structure data component
This commit is contained in:
parent
384aa87d06
commit
3299ed0fb1
|
@ -6,6 +6,7 @@ sidebar_position: 3
|
||||||
---
|
---
|
||||||
|
|
||||||
import { FaqAccordion } from "/src/components/FaqAccordion";
|
import { FaqAccordion } from "/src/components/FaqAccordion";
|
||||||
|
import { FaqStructuredData } from "/src/components/FaqStructuredData";
|
||||||
|
|
||||||
export const Faq = {
|
export const Faq = {
|
||||||
"general": [
|
"general": [
|
||||||
|
@ -184,10 +185,11 @@ export const Faq = {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
<FaqStructuredData faqs={Faq} />
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
{<FaqAccordion rows={Faq.general} slug="general" />}
|
<FaqAccordion rows={Faq.general} slug="general" />
|
||||||
|
|
||||||
## Android Client
|
## Android Client
|
||||||
|
|
||||||
|
|
|
@ -67,32 +67,10 @@ export const FaqAccordion = ({
|
||||||
rows,
|
rows,
|
||||||
slug,
|
slug,
|
||||||
}: { rows: Faq[]; slug: string }): JSX.Element => {
|
}: { rows: Faq[]; slug: string }): JSX.Element => {
|
||||||
// Set the faq structured data
|
|
||||||
const faqStructuredData = {
|
|
||||||
"@context": "https://schema.org",
|
|
||||||
"@type": "FAQPage",
|
|
||||||
mainEntity: rows.map((row) => ({
|
|
||||||
"@type": "Question",
|
|
||||||
name: row.title,
|
|
||||||
acceptedAnswer: {
|
|
||||||
"@type": "Answer",
|
|
||||||
text: row.content,
|
|
||||||
},
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BrowserOnly fallback={<div>Loading FAQ's...</div>}>
|
<BrowserOnly fallback={<div>Loading FAQ's...</div>}>
|
||||||
{() => {
|
{() => {
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<script
|
|
||||||
type="application/ld+json"
|
|
||||||
// biome-ignore lint: we need dangerouslySetInnerHTML here, and since we're the ones setting the content it's should be safe
|
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: JSON.stringify(faqStructuredData),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Accordion
|
<Accordion
|
||||||
allowMultipleExpanded={true}
|
allowMultipleExpanded={true}
|
||||||
allowZeroExpanded={true}
|
allowZeroExpanded={true}
|
||||||
|
@ -113,7 +91,6 @@ export const FaqAccordion = ({
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
))}
|
))}
|
||||||
</Accordion>
|
</Accordion>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
</BrowserOnly>
|
</BrowserOnly>
|
||||||
|
|
20
src/components/FaqStructuredData.tsx
Normal file
20
src/components/FaqStructuredData.tsx
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
export const FaqStructuredData = ({ faqs }) => {
|
||||||
|
const allFaqs = Object.values(faqs).flat();
|
||||||
|
|
||||||
|
const structuredData = {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "FAQPage",
|
||||||
|
mainEntity: allFaqs.map((faq) => ({
|
||||||
|
"@type": "Question",
|
||||||
|
name: faq.title,
|
||||||
|
acceptedAnswer: {
|
||||||
|
"@type": "Answer",
|
||||||
|
text: faq.content,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<script type="application/ld+json">{JSON.stringify(structuredData)}</script>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in a new issue