Giter Site home page Giter Site logo

gfscott / eleventy-plugin-youtube-embed Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 10.0 520 KB

An Eleventy plugin to automatically embed YouTube videos in posts

Home Page: https://gfscott.com/embed-everything/

JavaScript 86.84% TypeScript 13.16%
eleventy eleventy-plugin youtube 11ty 11ty-plugin

eleventy-plugin-youtube-embed's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

eleventy-plugin-youtube-embed's Issues

Use lite-youtube-embed

lite-youtube-embed is an awesome npm package that makes YouTube embeds way faster and more privacy respectful.

It would be lovely if the embed generated by this plugin could be generated through it.

Figure out the right approach to the `allow` attribute

YouTube has recently expanded the values it includes in the allow attribute on the embed’s iframe element. Here’s what gets included by default:

allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"

Investigate how to properly support allow.

Error deploying : lite-yt-embed.css missing

Error: ENOENT: no such file or directory, open '/vercel/path2/node_modules/eleventy-plugin-youtube-embed/node_modules/lite-youtube-embed/src/lite-yt-embed.css'

Deploying from Vercel with both 1.5 and 1.6.1

Doesn't Seem to Render on My Install - just spits out the link as text

I only know enough to be dangerous here so I'm sorry if I don't pass along enough info to help out.

Blog post code:

Blog post output:

Eleventy.js code:

Node Modules directory:

If there's anything else you'd need to see to help figure out the issue, I'm happy to send it over! (and no panic / rush. Just a personal blog. Thanks for the plugin!)

Tried it, but didn't work

Your plugin sounds great, but I couldn't get it to work. My Markdown parser produced the following HTML, so you may immediately see what the problem was (i.e., maybe it's because it's not on the same line as the <p> and the </p> tags):

<p>
    www.youtube.com/watch?v=u8pCsfT1gDU
</p>

And I had also tried it with https: in front. Either way, it only kept getting changed into just a link without the embed occurring.

Build failed in Travis CI. (Works fine on desktop)

TravisCI throws the following error when it tries to build:

`SyntaxError` was thrown:
    SyntaxError: Invalid regular expression: /<p>(\s*)(<a(.*)>)?(\s*)(https?:\/\/)?(w{3}\.)?(youtube\.com|youtu\.be)\/(watch\?v=|embed\/)?(?<videoId>[A-Za-z0-9-_]{11})(\S*)(\s*)(<\/a>)?(\s*)<\/p>/: Invalid group
        at extractVideoId (/home/travis/build/jmschrack/jmschrack.github.io/node_modules/eleventy-plugin-youtube-embed/.eleventy.js:35:25)
        at /home/travis/build/jmschrack/jmschrack.github.io/node_modules/eleventy-plugin-youtube-embed/.eleventy.js:20:21
        at Array.forEach (<anonymous>)
        at Template.eleventyConfig.addTransform (/home/travis/build/jmschrack/jmschrack.github.io/node_modules/eleventy-plugin-youtube-embed/.eleventy.js:19:13)
        at Template.runTransforms (/home/travis/build/jmschrack/jmschrack.github.io/node_modules/@11ty/eleventy/src/Template.js:387:29)
        at Template.renderPageEntry (/home/travis/build/jmschrack/jmschrack.github.io/node_modules/@11ty/eleventy/src/Template.js:539:28)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:189:7)

However, running eleventy locally works fine with no issues.

Add embed class and ID

Currently the embed is basically impossible to target with CSS. Each instance should have:

  • A unique id value, perhaps the youtube video ID
  • A common class, so all instances can be styled consistently

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.