Skip to content

Commit

Permalink
fixup! feat(FAQJsonLd): add new json ld component for FAQ pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ifiokjr committed Jan 9, 2020
1 parent 094d316 commit ae2a2b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -45,6 +45,7 @@ This codebase was initially forked from the brilliant [next-seo](https://github.
- [Book](#book) - [Book](#book)
- [Speakable](#speakable) - [Speakable](#speakable)
- [FAQ](#faq) - [FAQ](#faq)
- [Question Interface](#question-interface)
- [Course](#course) - [Course](#course)
- [Corporate Contact (Deprecated)](#corporate-contact-deprecated) - [Corporate Contact (Deprecated)](#corporate-contact-deprecated)
- [Local Business](#local-business) - [Local Business](#local-business)
Expand Down Expand Up @@ -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 ### Course


```tsx ```tsx
Expand Down
2 changes: 1 addition & 1 deletion src/jsonld/__tests__/jsonld.test.tsx
Expand Up @@ -308,7 +308,7 @@ test('ProductJsonLd', () => {
test('FAQJsonLd', () => { test('FAQJsonLd', () => {
render( render(
<FAQJsonLd <FAQJsonLd
mainEntity={[ questions={[
{ question: 'What?', answer: 'Stand' }, { question: 'What?', answer: 'Stand' },
{ question: 'How?', answer: 'Effort' }, { question: 'How?', answer: 'Effort' },
{ question: 'Why?', answer: 'Peace' }, { question: 'Why?', answer: 'Peace' },
Expand Down
11 changes: 8 additions & 3 deletions src/jsonld/faq.tsx
Expand Up @@ -15,10 +15,15 @@ export interface FAQJsonLdProps extends DeferSeoProps, Overrides<FAQPage> {
* An array of Question elements which comprise the list of answered questions * An array of Question elements which comprise the list of answered questions
* that this FAQPage is about. * 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 * The full text of the question. For example, "How long does it take to
* process a refund?". * process a refund?".
Expand Down Expand Up @@ -78,7 +83,7 @@ const transformMainEntity = (questions: Question[]): SchemaQuestion[] =>
* *
* @public * @public
*/ */
export const FAQJsonLd: FC<FAQJsonLdProps> = ({ mainEntity, overrides = {}, defer = false }) => { export const FAQJsonLd: FC<FAQJsonLdProps> = ({ questions: mainEntity, overrides = {}, defer = false }) => {
const json: WithContext<FAQPage> = { const json: WithContext<FAQPage> = {
'@context': 'https://schema.org', '@context': 'https://schema.org',
'@type': 'FAQPage', '@type': 'FAQPage',
Expand Down

0 comments on commit ae2a2b6

Please sign in to comment.