sampotts / shr

Simple, clean, and customizable social sharing buttons.
MIT License
152 stars 22 forks source link

YouTube Subscribe and Subscriber Count Button #20

Closed danpastori closed 5 years ago

danpastori commented 5 years ago

So in this PR, I added the YouTube Subscribe/Subscriber Count Button. Since this calls the YouTube API, you will need a public API key for YouTube. Without it, the subscriber count will return null and no count will appear. You will also need to define your channel name in the setup.

Example Setup Call

shr.setup({debug:!0, youtube_subscribe: {
    key: '{KEY}',
    channel: 'serversideupnet'
}})

Example Subscriber Button

<a
href="https://www.youtube.com/user/serversideupnet?sub_confirmation=1"
target="_blank"
class="shr-button shr-button-youtube"
data-shr-network="youtube_subscribe"
>
  <svg><use xlink:href="#shr-youtube"></use></svg>Subscribe
</a>

This PR also includes the proper styling and the YouTube icon. Let me know if you need any changes!