MichaelDeBoey / gatsby-remark-embedder

Gatsby Remark plugin to embed well known services by their URL.
MIT License
297 stars 59 forks source link

Support Slides.com #8

Closed MichaelDeBoey closed 4 years ago

MichaelDeBoey commented 5 years ago

By request of @codepunkt: add support for Slides.com.

https://help.slides.com/knowledgebase/articles/880650-embed-api

anuraghazra commented 5 years ago

I tried to implement this, seems like it's a bit tricky to implement the shouldTransform check because slides don't have a distinct url to check for embeds

i tried this approach, is it good? do you have any idea how we can do it?

(host === 'slides.com' || host === 'www.slides.com') && !!pathname.match(/^\/.*\w\/.*\w\/?[^embed].\/?$/ig)

although it fails in this case

    'Slides url (valid) with extra pathname': {
      url: 'https://slides.com/news/math/asdasd',
      valid: false,
    },
anuraghazra commented 5 years ago

above check passes in all these tests

  {
    'non-Slides url': {
      url: 'https://not-a-slides-url.com',
      valid: false,
    },
    "non-Slides url ending with 'slides.com'": {
      url: 'https://this-is-not-slides.com',
      valid: false,
    },
    "non-Slides url ending with 'slides.com' and having '/embed/'": {
      url: 'https://this-is-not-codepen.io/news/math/embed',
      valid: false,
    },
    'explore page': {
      url: 'https://slides.com/explore',
      valid: false,
    },
    'random page': {
      url: 'https://slides.com/random-page',
      valid: false,
    },
    'Slides embed url': {
      url: 'https://slides.com/news/math/embed',
      valid: false,
    },
    'Slides embed url with trailing slash': {
      url: 'https://slides.com/news/math/embed/',
      valid: false,
    },
    'Slides homepage': {
      url: 'https://slides.com/',
      valid: false,
    },
    'Slides url': {
      url: 'https://slides.com/news/math',
      valid: true,
    },
    'Slides user slide': {
      url: 'https://slides.com/valentinogagliardi/django-rest#/1',
      valid: true,
    },
    'Slides url with trailing slash': {
      url: 'https://slides.com/news/math/',
      valid: true,
    },
    "Slides url having 'www' subdomain": {
      url: 'https://www.slides.com/news/math',
      valid: true,
    },
  }
MichaelDeBoey commented 5 years ago

@anuraghazra can you please open a (draft) PR so we can discuss it there? 🤔

MichaelDeBoey commented 4 years ago

:tada: This issue has been resolved in version 1.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: