Skip to content

Commit

Permalink
Structured data for FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed Mar 17, 2024
1 parent 85e9f25 commit c86180f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
43 changes: 32 additions & 11 deletions src/components/widgets/FAQs.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { Icon } from 'astro-icon/components';
import { Icon } from "astro-icon/components";
interface Item {
question: string;
Expand All @@ -14,14 +14,14 @@ export interface Props {
}
const {
title = await Astro.slots.render('title'),
subtitle = await Astro.slots.render('subtitle'),
title = await Astro.slots.render("title"),
subtitle = await Astro.slots.render("subtitle"),
highlight,
items = [],
} = Astro.props;
---

<div class="px-4 py-16 mx-auto max-w-6xl lg:py-20">
<article class="px-4 py-16 mx-auto max-w-6xl lg:py-20">
<div class="max-w-xl sm:mx-auto lg:max-w-2xl">
{
(title || subtitle || highlight) && (
Expand All @@ -38,7 +38,12 @@ const {
set:html={title}
/>
)}
{subtitle && <p class="max-w-3xl mx-auto text-xl text-muted dark:text-slate-400" set:html={subtitle} />}
{subtitle && (
<p
class="max-w-3xl mx-auto text-xl text-muted dark:text-slate-400"
set:html={subtitle}
/>
)}
</div>
)
}
Expand All @@ -50,17 +55,33 @@ const {
items.map((subitems) => (
<div class="space-y-8">
{subitems.map(({ question, answer }) => (
<div>
<section
itemprop="mainEntity"
itemscope
itemtype="http://schema.org/Question"
>
<h3 class="mb-4 text-xl font-bold">
<Icon name="tabler:arrow-down-right" class="w-7 h-7 text-primary inline-block" />
{question}
<Icon
name="tabler:arrow-down-right"
class="w-7 h-7 text-primary inline-block"
/>
<span itemprop="name">{question}</span>
</h3>
{answer && <div class="text-muted dark:text-gray-400" set:html={answer} />}
</div>
{answer && (
<div
itemscope
itemprop="acceptedAnswer"
itemtype="https://schema.org/Answer"
class="text-muted dark:text-gray-400"
>
<span itemprop="text" set:html={answer} />
</div>
)}
</section>
))}
</div>
))
}
</div>
</div>
</div>
</article>
16 changes: 8 additions & 8 deletions src/layouts/PageLayout.astro
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
import Layout from '~/layouts/BaseLayout.astro';
import Header from '~/components/widgets/Header.astro';
import Footer from '~/components/widgets/Footer.astro';
import Announcement from '~/components/widgets/Announcement.astro';
import Layout from "~/layouts/BaseLayout.astro";
import Header from "~/components/widgets/Header.astro";
import Footer from "~/components/widgets/Footer.astro";
import { headerData, footerData } from '~/data';
import { headerData, footerData } from "~/data";
import { MetaSEO } from '~/types';
import type { MetaSEO } from "~/types";
export interface Props {
meta?: MetaSEO;
itemtype?: string;
}
const { meta } = Astro.props;
const { meta, itemtype } = Astro.props;
---

<Layout {meta}>
<slot name="header">
<Header {...headerData} isSticky showToggleTheme />
</slot>
<main>
<main itemscope itemtype={itemtype}>
<slot />
</main>
<slot name="footer">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/docs/faq.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const meta = {
};
---

<Layout {meta}>
<Layout {meta} itemtype="http://schema.org/FAQPage">
<FAQs
highlight="FAQs"
title="Sending"
Expand Down

0 comments on commit c86180f

Please sign in to comment.