Skip to content

Commit

Permalink
feat: VideoGame schema type support (#770)
Browse files Browse the repository at this point in the history
* feat: `VideoGame` schema type support

* chore: video game prop name changed

* docs: `VideoGame` schema
  • Loading branch information
hsynlms committed Jun 18, 2021
1 parent 78789d2 commit 9d9c91d
Show file tree
Hide file tree
Showing 17 changed files with 1,019 additions and 257 deletions.
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ looking for inspiration on what to add.
- [Social Profile](#social-profile)
- [News Article](#news-article)
- [Video](#video-1)
- [VideoGame](#videogame)
- [Event](#event)
- [Q&A](#qa)
- [Collection Page](#collection-page)
Expand Down Expand Up @@ -1919,6 +1920,95 @@ export default Page;
| `publication` | If your video is happening live and you want to be eligible for the LIVE badge. |
| `regionsAllowed` | The regions where the video is allowed. |

### VideoGame

```jsx
import { VideoGameJsonLd } from 'next-seo';

const Page = () => (
<>
<h1>VideoGame JSON-LD</h1>
<VideoGameJsonLd
name="Red Dead Redemption 2"
translatorName={['Translator 1', 'Translator 2']}
languageName={['English', 'Kurdish']}
description="Arthur Morgan and the Van der Linde gang are outlaws on the run. With federal agents and the best bounty hunters in the nation massing on their heels, the gang must rob, steal and fight their way across the rugged heartland of America in order to survive."
processorRequirements="4 GHz"
memoryRequirements="16 Gb"
playMode="SinglePlayer"
applicationCategory="Game"
url="https://example.com/rdr2-game"
platformName={['PC game', 'PlayStation 4']}
operatingSystemName="windows"
keywords="outlaw, gang, federal agents"
datePublished="2019-02-05T08:00:00+08:00"
image="https://example.com/photos/1x1/photo.jpg"
publisherName="Vertical Games"
producerName="Rockstar Games"
producerUrl="https//www.example.com/producer"
offers={[
{
price: '119.99',
priceCurrency: 'USD',
priceValidUntil: '2020-11-05',
availability: 'https://schema.org/InStock',
url: 'https://example.net/rdr2-game',
seller: {
name: 'Executive Gaming',
},
},
{
price: '139.99',
priceCurrency: 'CAD',
priceValidUntil: '2020-09-05',
availability: 'https://schema.org/InStock',
url: 'https://example.org/rdr2-game',
seller: {
name: 'Executive Gaming',
},
},
]}
aggregateRating={{
ratingValue: '44',
reviewCount: '89',
ratingCount: '684',
bestRating: '100',
}}
reviews={[
{
author: {
type: 'Person',
name: 'AhmetKaya',
},
publisher: {
type: 'Organization',
name: 'Gam Production',
},
datePublished: '2017-01-06T03:37:40Z',
reviewBody: 'Iki gozum.',
name: 'Rica ederim.',
reviewRating: {
bestRating: '5',
ratingValue: '5',
worstRating: '1',
},
},
]}
/>
</>
);

export default Page;
```

**Required properties**

| Property | Info |
| -------- | ---------------------------- |
| `name` | The title of the video game. |

[More information about the schema](https://schema.org/VideoGame)

### Event

```jsx
Expand Down
105 changes: 104 additions & 1 deletion cypress/e2e/jsonld.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertSchema } from '@cypress/schema-tools';
import schemas from '../schemas';

const expectedJSONResults = 22;
const expectedJSONResults = 23;

const articleLdJsonIndex = 0;
const breadcrumbLdJsonIndex = 1;
Expand All @@ -25,6 +25,7 @@ const qaPageLdJsonIndex = 18;
const softwareAppJsonIndex = 19;
const collectionPageLdJsonIndex = 20;
const profilePageLdJsonIndex = 21;
const videoGameLdJsonIndex = 22;

describe('Validates JSON-LD For:', () => {
it('Article', () => {
Expand Down Expand Up @@ -1742,4 +1743,106 @@ describe('Validates JSON-LD For:', () => {
expect(jsonLD).to.deep.equal(expectedObject);
});
});

it('VideoGame', () => {
cy.visit('http://localhost:3000/jsonld');
cy.get('head script[type="application/ld+json"]')
.should('have.length', expectedJSONResults)
.then(tags => {
const jsonLD = JSON.parse(tags[videoGameLdJsonIndex].innerHTML);
assertSchema(schemas)('VideoGame', '1.0.0')(jsonLD);
});
});

it('VideoGame Matches', () => {
cy.visit('http://localhost:3000/jsonld');
cy.get('head script[type="application/ld+json"]')
.should('have.length', expectedJSONResults)
.then(tags => {
const jsonLD = JSON.parse(tags[videoGameLdJsonIndex].innerHTML);
expect(jsonLD).to.deep.equal({
'@context': 'https://schema.org/',
'@type': 'VideoGame',
name: 'Red Dead Redemption 2',
translator: ['Translator 1', 'Translator 2'],
inLanguage: ['English', 'Kurdish'],
description:
'Arthur Morgan and the Van der Linde gang are outlaws on the run. With federal agents and the best bounty hunters in the nation massing on their heels, the gang must rob, steal and fight their way across the rugged heartland of America in order to survive.',
processorRequirements: '4 GHz',
memoryRequirements: '16 Gb',
playMode: 'SinglePlayer',
applicationCategory: 'Game',
url: 'https://example.com/rdr2-game',
gamePlatform: ['PC game', 'PlayStation 4'],
operatingSystem: 'windows',
keywords: 'outlaw, gang, federal agents',
datePublished: '2019-02-05T08:00:00+08:00',
image: {
'@type': 'ImageObject',
url: 'https://example.com/photos/1x1/photo.jpg',
},
publisher: 'Vertical Games',
producer: {
'@type': 'Organization',
name: 'Rockstar Games',
sameAs: 'https//www.example.com/producer',
},
offers: [
{
'@type': 'Offer',
price: '119.99',
priceCurrency: 'USD',
priceValidUntil: '2020-11-05',
availability: 'https://schema.org/InStock',
url: 'https://example.net/rdr2-game',
seller: {
'@type': 'Organization',
name: 'Executive Gaming',
},
},
{
'@type': 'Offer',
price: '139.99',
priceCurrency: 'CAD',
priceValidUntil: '2020-09-05',
availability: 'https://schema.org/InStock',
url: 'https://example.org/rdr2-game',
seller: {
'@type': 'Organization',
name: 'Executive Gaming',
},
},
],
aggregateRating: {
'@type': 'AggregateRating',
ratingValue: '44',
reviewCount: '89',
ratingCount: '684',
bestRating: '100',
},
review: [
{
'@type': 'Review',
author: {
'@type': 'Person',
name: 'AhmetKaya',
},
publisher: {
'@type': 'Organization',
name: 'Gam Production',
},
datePublished: '2017-01-06T03:37:40Z',
reviewBody: 'Iki gozum.',
name: 'Rica ederim.',
reviewRating: {
'@type': 'Rating',
bestRating: '5',
ratingValue: '5',
worstRating: '1',
},
},
],
});
});
});
});
141 changes: 141 additions & 0 deletions cypress/schemas/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,70 @@ export const seller100 = {
},
};

export const provider100 = {
version: {
major: 1,
minor: 0,
patch: 0,
},
schema: {
type: 'object',
description: 'Provider',
properties: {
'@type': {
type: 'string',
description: 'Provider type',
},
name: {
type: 'string',
description: 'Provider name',
},
sameAs: {
type: 'string',
description: 'Provider url',
},
},
additionalProperties: false,
example: {
'@type': 'Organization',
name: 'Course',
sameAs: 'https//www.example.com/provider',
},
},
};

export const producer100 = {
version: {
major: 1,
minor: 0,
patch: 0,
},
schema: {
type: 'object',
description: 'Producer',
properties: {
'@type': {
type: 'string',
description: 'Producer type',
},
name: {
type: 'string',
description: 'Producer name',
},
sameAs: {
type: 'string',
description: 'Producer url',
},
},
additionalProperties: false,
example: {
'@type': 'Organization',
name: 'Course',
sameAs: 'https//www.example.com/producer',
},
},
};

export const offers100 = {
version: {
major: 1,
Expand Down Expand Up @@ -367,3 +431,80 @@ export const review100 = {
},
},
};

export const exampleVideo = {
'@type': 'VideoObject',
name: 'How to make a Party Coffee Cake',
description: 'This is how you make a Party Coffee Cake.',
thumbnailUrl: [
'https://example.com/photos/1x1/photo.jpg',
'https://example.com/photos/4x3/photo.jpg',
'https://example.com/photos/16x9/photo.jpg',
],
contentUrl: 'http://www.example.com/video123.mp4',
embedUrl: 'http://www.example.com/videoplayer?video=123',
uploadDate: '2018-02-05T08:00:00+08:00',
duration: 'PT1M33S',
interactionStatistic: {
'@type': 'InteractionCounter',
interactionType: { '@type': 'https://schema.org/WatchAction' },
userInteractionCount: 2347,
},
expires: '2019-02-05T08:00:00+08:00',
};

export const videoObject100 = {
version: {
major: 1,
minor: 0,
patch: 0,
},
schema: {
type: 'object',
title: 'Video Object',
description: 'A video',
properties: {
'@type': {
type: 'string',
description: 'Schema.org type',
},
name: {
type: 'string',
description: 'The name of the recipe.',
},
description: {
type: 'string',
description: 'The description of the recipe.',
},
thumbnailUrl: {
type: 'array',
items: {
type: 'string',
},
description: 'Array of images for the video.',
},
contentUrl: {
type: 'string',
description: 'URL for the content of the video',
},
embedUrl: {
type: 'string',
description: 'URL for the embed version of the video',
},
uploadDate: {
type: 'string',
description: 'Upload date of the video',
},
duration: {
type: 'string',
description: 'Duration of the video',
},
expires: {
type: 'string',
description: 'Expiration date of the video',
},
},
additionalProperties: true,
},
example: exampleVideo,
};

0 comments on commit 9d9c91d

Please sign in to comment.