New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gridsome-remark-plugin-youtube

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gridsome-remark-plugin-youtube

Gridsome Remark plugin to embed YouTube videos

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Gridsome Remark YouTube Plugin

This is a plugin for Gridsome's chosen markdown engine, Remark, and allows you to embed YouTube videos in markdown files.

Installation

npm i gridsome-plugin-remark-youtube
# yarn add gridsome-plugin-remark-youtube

Loading

module.exports = {
  plugins: [
    {
      use: '@gridsome/source-filesystem',
      options: {
        path: 'blog/**/*.md',
        route: '/blog/:year/:month/:day/:slug',
        remark: {
          plugins: [
            ['gridsome-plugin-remark-youtube']
          ]
        }
      }
    }
  ]
}

Options

There are options to change width of the video, and whether the video is left aligned or centred:

  • width Default 100%. Set to any valid CSS width.
  • align Default 0. The default left aligns the video. Set to auto to align the video centrally.

Loading with options:

module.exports = {
  plugins: [
    {
      use: '@gridsome/source-filesystem',
      options: {
        path: 'blog/**/*.md',
        route: '/blog/:year/:month/:day/:slug',
        remark: {
          plugins: [
            ['gridsome-plugin-remark-youtube', {width: '500px', align: 'auto'}]
          ]
        }
      }
    }
  ]
}

Usage

This plugin uses the same markdown syntax as the Gatsby plugin, with backticks (`) and a youtube: prefix, followed by the YouTube URL. Any valid YouTube URL should work.

`youtube:https://www.youtube.com/watch?v=dQw4w9WgXcQ`

or

`youtube:https://www.youtube.com/embed/dQw4w9WgXcQ`

or

`youtube:https://youtu.be/dQw4w9WgXcQ`

Output

Video

This is how the video should appear on the screen:

Generated HTML

This is the HTML that is being generated by the plugin and injected into the page:

<div style="width: 100%; margin: 0 auto;"><div style="position: relative; padding-bottom: 56.25%; padding-top: 25px; height: 0;"><iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" src="https://www.youtube.com/embed/dQw4w9WgXcQ"></iframe></div></div>

License

MIT

Credit

Some of the code in this plugin was copied from the Gatsby plugin for embedding YouTube videos in markdown:

https://github.com/ntwcklng/gatsby-remark-embed-youtube

To figure out how to convert the above plugin to a Gridsome plugin, I cribbed from Gridsome's Twitter Remark plugin:

https://github.com/danvega/gridsome-plugin-remark-twitter

Keywords

FAQs

Package last updated on 23 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc