# videojs-schema

> Injects JSON-LD metadata into the DOM for SEO

Latest version **0.8.0** (published 2023-12-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install videojs-schema
pnpm add videojs-schema
yarn add videojs-schema
bun add videojs-schema
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2023-12-04 |
| First published | 2019-02-27 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 2 |
| Unpacked size | 1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | mister-ben |
| Maintainers | misterben |
| Keywords | videojs, videojs-plugin |

## Links

- npm: https://www.npmjs.com/package/videojs-schema
- Repository: https://github.com/brightcove/videojs-schema
- Homepage: https://github.com/brightcove/videojs-schema#readme
- Issues: https://github.com/brightcove/videojs-schema/issues
- npm.io page: https://npm.io/package/videojs-schema

## Dependencies (2)

- [global](https://npm.io/package/global.md) ^4.4.0
- [video.js](https://npm.io/package/video.js.md) ^6 || ^7

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.8.0 (latest) — 2023-12-04
- 0.6.1 (beta) — 2021-09-09
- 0.7.0 — 2022-11-22
- 0.6.2 — 2022-02-09
- 0.6.0 — 2021-09-08
- 0.5.0 — 2021-05-24
- 0.5.0-beta.6 — 2020-03-30
- 0.5.0-beta.5 — 2020-02-08
- 0.5.0-beta.4 — 2020-02-08
- 0.5.0-beta.3 — 2019-10-30
- 0.5.0-beta.2 — 2019-09-05
- 0.5.0-beta.1 — 2019-09-04
- 0.5.0-beta.0 — 2019-08-12
- 0.4.0 — 2019-04-18
- 0.3.2 — 2019-03-12
- … 2 more at https://npm.io/package/videojs-schema/versions

## README

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [videojs-schema](#videojs-schema)
  - [Options](#options)
  - [Description metadata](#description-metadata)
  - [Install](#install)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# videojs-schema

A plugin for the Brightcove Player to inject metadata from a Video Cloud video in to the page as [Schema.org](https://schema.org/VideoObject) structured data. It uses the JSON-LD format [supported by Google for video SEO](https://developers.google.com/search/docs/guides/intro-structured-data), e.g.

```html
<script type="application/ld+json">
{
  "@context":"http://schema.org/",
  "@type":"VideoObject",
  "name":"Big Buck Bunny",
  "description":"(c) copyright 2008, Blender Foundation / www.bigbuckbunny.org",
  "thumbnailUrl":"https://cf-images.eu-west-1.prod.boltdns.net/v1/static/906043040001/f7d56300-ffca-460d-8ff6-fef835c12b36/e284fdba-d15a-422f-bebc-6a355e3d4dd3/1280x720/match/image.jpg",
  "uploadDate":"2016-10-20",
  "@id":"http://players.brightcove.net/906043040001/5WnZb7ptr_default/index.html?videoId=ref:bunnyfull",
  "duration":"PT10M35S",
  "embedUrl":"http://players.brightcove.net/906043040001/5WnZb7ptr_default/index.html?videoId=1401169490001"
}
</script>
```

As seen by Google: https://search.google.com/structured-data/testing-tool/u/0/#url=http%3A%2F%2Fplayers.brightcove.net%2F906043040001%2F5WnZb7ptr_default%2Findex.html%3FvideoId%3Dref%3Abunnyfull

The embedUrl is only included if the social plugin is present and its `removeEmbed` option is not `true`.

## Options

`schemaId` - the value to use as `@id` in the metadata. This must be a unique URI which represents the video, but not necessarily a "real" URL. This is arbitrary and might be a value like `https://mydomain.com/videos/{id}` or `https://videos.mydomain.com#{id}` or `https://mydomain.com/article-about-video-{id}#the-video`.

Accepts `{id}`, `{referenceId}`, `{playerId}`,  `{embedId}` and `{accountId}` as macros.

Defaults to `https://players.brightcove.net/{accountId}/{playerId}_{embedId}/index.html?videoId={id}`

`keywords` - if `true`, include tags as keywords. Default is `false`.

`excludeTags` - array of tags to not include as keywords in the schema metadata, e.g. `["youtubesync"]`

`baseObject` - an option object of properties onto which to build the video specific metadata. For example this could be used to include a publisher object:

`includeEmbedUrl` - if `false`, no embed url is included. Inlcuding thisURL may be expected by search engines. Default is `true`.

`skipRules` - used to exclude videos from having schema metadata generated, based on their video cloud metadata. Can be tags and / or custom fields. If multiple tags, fields or both are specified, matching any excludes.

`skipRules.customFields` - any object of field-value pairs. If a field present and set to the value in the video's custom fields, no schema metadata is created. e.g. `{category: 'unlisted'}`

`skipRules.tags` - any array of one or more tags. If any one is present in the video's metadata, no schema metadata is created. e.g. `['notthistag']`

`transcript` - if `true`, a captions or subtitles track with a matching language will be added as a transcript. Default is `false`.

`transcriptMatchAny` - if `true` and `transcript` is also `true`, a transcript will be added from the first usable track, if there is no language match. Default is `false`.

```json
"baseObject": {
  "publisher": {
    "@type": "Organization",
    "name": "Publisher name",
    "logo": {
      "@type": "ImageObject",
      "url": "https://example.com/logo.jpg",
      "width": 600,
      "height": 60
    }
  }
}
```

`preferLongDescription` - if `true`, use the long description if available. If `false`, or `true` and long description is not set then the (short) description field will be used. Default is `false`.

## Description metadata
By default, the short description field is used as the description text. If the `preferLongDescription` option is set, the long description will be used instead, falling back to short description if empty. If the short description (or both long and short descriptions with `preferLongDescription`) is empty, then the title is used since no description is considered invlaid schema.

## Install

Add [as a plugin to a player in Video Cloud Studio][plugins]:

- Under "plugins" click "add a plugin", 'custom plugin"
- Plugin name is `schema`
- Javascript URL is `https://cdn.jsdelivr.net/npm/videojs-schema/dist/videojs-schema.min.js`
- No CSS
- Leave blank unless using options above, in which case

```json
{
  "schemaId": "https://example.com/my/url/{id}"
}
```

- Save, then publish

[plugins]: [https://support.brightcove.com/configuring-player-plugins]

---
_Source: https://npm.io/package/videojs-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
