npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nuxt-youtube-subscribe-module

v0.1.2

Published

Youtube Subscribe Module for Nuxt.js

Downloads

2

Readme

Nuxt Youtube Subscribe Module

Youtube Subscribe integration for Nuxt.js. You could add the official subscribe button to the desired Youtube channel.

This nuxt module is a simple wrapper of the official Youtube Subscribe Button.

✍🏻 Motivation

This module is the result of the need of add a Youtube subscribe button in one of my multiple web applitacions. After google it I only was able to find the official Youtube Subscribe Button, but it only works well in simple JS applications or fullstack ones made with CMS like WordPress, Drupal and more.

As I didn't find any solution for vue apps, I decided to develop this module for nuxt because is the Vue framework I am using majority.

I hope this module be very usefull for so many people with same need than me.

🧱 Install

You must add nuxt-youtube-subscribe-module dependency using yarn or npm to your project

$ npm install nuxt-youtube-subscribe-module --save

or

$ yarn add nuxt-youtube-subscribe-module

⚙️ Config

You have to add nuxt-youtube-subscribe-module to modules section of nuxt.config.js

// nuxt.config.js
{
  ...,
  modules: [
    'nuxt-youtube-subscribe-module'.
  ],
  ...,
}

If you want to use the module options you have two ways of doing this:

// nuxt.config.js
// Simple usage
{
  ...,
  modules: [
    ['nuxt-youtube-subscribe-module', {
      tag: 'YoutubeSubscribeButton'
    }]
  ],
  ...,
}
// nuxt.config.js
// Using top level options
{
  ...,
  modules: [
    'nuxt-youtube-subscribe-module'
  ],
  ...,
  'youtube-subscribe': {
    tag: 'YoutubeSubscribeButton'
  },
  ...,
}

Configuration options

| Option | type | description | -------- | ---- | ----------- | tag | String | Optional. Desired name for the component used to embed the Youtube subscribe button. Defaults to youtube-subscribe-button.

▶️ Usage

For using this module you only have to add the <youtube-subscribe-button> tag in the desired location.

Example 1: Same that official docs shows by default

<!-- view.html -->
<youtube-subscribe-button
  identifier="my-subscribe-button"
  channel="GoogleDevelopers"
></youtube-subscribe-button>

Example 2: Official docs example with all options

<!-- view.html -->
<youtube-subscribe-button
  identifier="my-subscribe-button"
  channel="GoogleDevelopers"
  layout="full"
  theme="dark"
></youtube-subscribe-button>

Example 3: Custom options

// nuxt.config.js
{
  ...,
  modules: [
    ['nuxt-youtube-subscribe-module', {
      tag: 'YoutubeSubscribeButton'
    }]
  ],
  ...,
}
<!-- view.html -->
<YoutubeSubscribeButton
  identifier="my-subscribe-button"
  channel="GoogleDevelopers"
  layout="full"
></YoutubeSubscribeButton>

Component props:

| prop | type | description | ---- | ---- | ----------- | identifier | String | Required. Unique string to be used as id in the subscribe button. | channelid | String | Required conditionally if no channel is present. Unique string that identifies the Youtube channel used to the subscribe button. | channel | String | Required conditionally if no channelid is present. Unique string that identifies the Youtube channel used to the subscribe button. | layout | String | Optional. Desired layout for the subscribe button. Available values are default and full. Defaults to default. | theme | String | Optional. Desired theme for the subscribe button. Available values are (empty string) and dark. Defaults to . | count | String | Optional. For indicate the visibility of subscribers count. Available values are default and hidden. Defaults to default.

How does this module work❓

Module (when app starts)

  1. The module overwrites all default options with the given ones.
  2. The module loads the plugin with the YoutubeSubscribeButton global Vue component.
  3. The module loads the Google JavaScript API.
  4. The youtube-subscribe:gapi-loaded custom event is fired for very quick components.

YoutubeSubscribeButton (when component is used)

  1. The component validates all props.
  2. All component options are collected.
  3. The subscribe button is rendered through render gapi (Google API) method if available.
  4. A listener for youtube-subscribe:gapi-loaded custom event is registered for a second retry for display the subscribe button.
  5. The subscribe button is rendered after fired from youtube-subscribe:gapi-loaded listener callback.