Skip to content
Permalink
Browse files

fixup! feat(FAQJsonLd): add new json ld component for FAQ pages

  • Loading branch information
ifiokjr committed Jan 9, 2020
1 parent 094d316 commit ae2a2b69b057aa52bf8c0a477a9bc097819783fa
Showing with 23 additions and 4 deletions.
  1. +14 −0 README.md
  2. +1 −1 src/jsonld/__tests__/jsonld.test.tsx
  3. +8 −3 src/jsonld/faq.tsx
@@ -45,6 +45,7 @@ This codebase was initially forked from the brilliant [next-seo](https://github.
- [Book](#book)
- [Speakable](#speakable)
- [FAQ](#faq)
- [Question Interface](#question-interface)
- [Course](#course)
- [Corporate Contact (Deprecated)](#corporate-contact-deprecated)
- [Local Business](#local-business)
@@ -928,6 +929,19 @@ export default () => (
);
```

| Property | Type | Description |
| -------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------- |
| [questions](#question-interface) | <code>Question[]</code> | An array of Question elements which comprise the list of answered questions that this FAQPage is about. |

#### Question Interface

The questions and answers for an FAQ Page.

| Property | Type | Description |
| ------------------------------------------------------------------------------------------------------------------------------ | ------------------- | ----------------------------------------------------------------------------------------- |
| [answer](https://github.com/ifiokjr/gatsby-plugin-next-seo/blob/master/docs/api/gatsby-plugin-next-seo.question.answer.md) | <code>string</code> | The answer to the question. There must be one answer per question. |
| [question](https://github.com/ifiokjr/gatsby-plugin-next-seo/blob/master/docs/api/gatsby-plugin-next-seo.question.question.md) | <code>string</code> | The full text of the question. For example, "How long does it take to process a refund?". |

### Course

```tsx
@@ -308,7 +308,7 @@ test('ProductJsonLd', () => {
test('FAQJsonLd', () => {
render(
<FAQJsonLd
mainEntity={[
questions={[
{ question: 'What?', answer: 'Stand' },
{ question: 'How?', answer: 'Effort' },
{ question: 'Why?', answer: 'Peace' },
@@ -15,10 +15,15 @@ export interface FAQJsonLdProps extends DeferSeoProps, Overrides<FAQPage> {
* An array of Question elements which comprise the list of answered questions
* that this FAQPage is about.
*/
mainEntity: Question[];
questions: Question[];
}

interface Question {
/**
* The questions and answers for an FAQ Page.
*
* @public
*/
export interface Question {
/**
* The full text of the question. For example, "How long does it take to
* process a refund?".
@@ -78,7 +83,7 @@ const transformMainEntity = (questions: Question[]): SchemaQuestion[] =>
*
* @public
*/
export const FAQJsonLd: FC<FAQJsonLdProps> = ({ mainEntity, overrides = {}, defer = false }) => {
export const FAQJsonLd: FC<FAQJsonLdProps> = ({ questions: mainEntity, overrides = {}, defer = false }) => {
const json: WithContext<FAQPage> = {
'@context': 'https://schema.org',
'@type': 'FAQPage',

0 comments on commit ae2a2b6

Please sign in to comment.
You can’t perform that action at this time.