1 | # Vue GitHub Buttons
|
2 | [![license](https://img.shields.io/github/license/gluons/vue-github-buttons.svg?style=flat-square)](https://github.com/gluons/vue-github-buttons/blob/master/LICENSE)
|
3 | [![vue 2](https://img.shields.io/badge/vue-2-42b983.svg?style=flat-square)](https://vuejs.org)
|
4 | [![npm](https://img.shields.io/npm/v/vue-github-buttons.svg?style=flat-square)](https://www.npmjs.com/package/vue-github-buttons)
|
5 | [![npm](https://img.shields.io/npm/dt/vue-github-buttons.svg?style=flat-square)](https://www.npmjs.com/package/vue-github-buttons)
|
6 | [![Travis](https://img.shields.io/travis/gluons/vue-github-buttons.svg?style=flat-square)](https://travis-ci.org/gluons/vue-github-buttons)
|
7 | [![Codacy grade](https://img.shields.io/codacy/grade/bc0ed4e4a9ef4734ae741d0f8a5d358d.svg?style=flat-square)](https://www.codacy.com/app/gluons/vue-github-buttons)
|
8 | [![ESLint Gluons](https://img.shields.io/badge/code%20style-gluons-9C27B0.svg?style=flat-square)](https://github.com/gluons/eslint-config-gluons)
|
9 |
|
10 | :octocat: GitHub buttons component for Vue.
|
11 |
|
12 | - [Vue GitHub Buttons](#vue-github-buttons)
|
13 | - [Installation](#installation)
|
14 | - [Demo](#demo)
|
15 | - [Usage](#usage)
|
16 | - [Using with Nuxt](#using-with-nuxt)
|
17 | - [Module options](#module-options)
|
18 | - [`css`](#css)
|
19 | - [`useCache`](#usecache)
|
20 | - [Using with VuePress](#using-with-vuepress)
|
21 | - [API](#api)
|
22 | - [Plugin Options](#plugin-options)
|
23 | - [`useCache`](#usecache-1)
|
24 | - [Components](#components)
|
25 | - [`gh-btns-watch`](#gh-btns-watch)
|
26 | - [`gh-btns-star`](#gh-btns-star)
|
27 | - [`gh-btns-fork`](#gh-btns-fork)
|
28 | - [`gh-btns-follow`](#gh-btns-follow)
|
29 |
|
30 | ## Installation
|
31 |
|
32 | Via [NPM](https://www.npmjs.com):
|
33 |
|
34 | [![NPM](https://nodei.co/npm/vue-github-buttons.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/vue-github-buttons)
|
35 |
|
36 | ```bash
|
37 | npm install -save vue-github-buttons
|
38 | ```
|
39 |
|
40 | Via [Yarn](https://yarnpkg.com):
|
41 |
|
42 | ```bash
|
43 | yarn add vue-github-buttons
|
44 | ```
|
45 |
|
46 | ## Demo
|
47 | Go to https://gluons.github.io/vue-github-buttons
|
48 |
|
49 | ## Usage
|
50 |
|
51 | ```javascript
|
52 | import Vue from 'vue';
|
53 | import VueGitHubButtons from 'vue-github-buttons';
|
54 | import App from './App.vue';
|
55 |
|
56 | // Stylesheet
|
57 | import 'vue-github-buttons/dist/vue-github-buttons.css';
|
58 |
|
59 | Vue.use(VueGitHubButtons);
|
60 | // Or if your don't want to use cache
|
61 | Vue.use(VueGitHubButtons, { useCache: false });
|
62 |
|
63 | new Vue({
|
64 | el: '#app',
|
65 | render: h => h(App)
|
66 | });
|
67 | ```
|
68 |
|
69 | ```vue
|
70 | <template>
|
71 | <div id="app">
|
72 | <gh-btns-watch slug="vuejs/vue" show-count></gh-btns-watch>
|
73 | <gh-btns-star slug="vuejs/vue" show-count></gh-btns-star>
|
74 | <gh-btns-fork slug="vuejs/vue" show-count></gh-btns-fork>
|
75 | <gh-btns-follow user="yyx990803" show-count></gh-btns-follow>
|
76 | </div>
|
77 | </template>
|
78 |
|
79 | <script>
|
80 | // JavaScript ...
|
81 | </script>
|
82 |
|
83 | <style>
|
84 | /* Style ... */
|
85 | </style>
|
86 | ```
|
87 |
|
88 | ## Using with [Nuxt](https://nuxtjs.org/)
|
89 |
|
90 | Add `vue-github-buttons/nuxt` to `modules` in **nuxt.config.js**.
|
91 |
|
92 | ```javascript
|
93 | module.exports = {
|
94 | modules: [
|
95 | 'vue-github-buttons/nuxt',
|
96 | // Or with options
|
97 | ['vue-github-buttons/nuxt', {
|
98 | css: false, // Don't include CSS
|
99 | useCache: false // Don't use cache
|
100 | }]
|
101 | ]
|
102 | };
|
103 | ```
|
104 |
|
105 | ### Module options
|
106 |
|
107 | #### `css`
|
108 | Type: `Boolean`
|
109 | Default: `true`
|
110 |
|
111 | Include **Vue GitHub Buttons**'s CSS.
|
112 |
|
113 | #### `useCache`
|
114 | Type: `Boolean`
|
115 | Default: `true`
|
116 |
|
117 | Enable caching. (See below)
|
118 |
|
119 | ## Using with [VuePress](https://vuepress.vuejs.org/)
|
120 |
|
121 | > Require **VuePress** v1.x
|
122 |
|
123 | Add **Vue GitHub Buttons** to your `plugins` in `.vuepress/config.js`.
|
124 |
|
125 | ```javascript
|
126 | const VueGitHubButtons = require('');
|
127 |
|
128 | module.exports = {
|
129 | plugins: [
|
130 | require('vue-github-buttons/plugins/vuepress'),
|
131 |
|
132 | /* Or using plugin with options */
|
133 |
|
134 | [
|
135 | require('vue-github-buttons/plugins/vuepress'),
|
136 | {
|
137 | useCache: false
|
138 | }
|
139 | ]
|
140 | ]
|
141 | }
|
142 | ```
|
143 |
|
144 | Plugin options are the same as [Vue plugin options](#plugin-options).
|
145 |
|
146 | ## API
|
147 |
|
148 | ### Plugin Options
|
149 |
|
150 | #### `useCache`
|
151 | Type: `Boolean`
|
152 | Default: `true`
|
153 |
|
154 | Enable count number caching. (Use [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage))
|
155 | > GitHub API has [limited requests](https://developer.github.com/v3/#rate-limiting). So, caching may be useful when user refresh the webpage.
|
156 |
|
157 | ```javascript
|
158 | Vue.use(VueGitHubButtons, { useCache: false }); // Disable cache
|
159 | ```
|
160 |
|
161 | ### Components
|
162 |
|
163 | #### `gh-btns-watch`
|
164 | 👁️ A watch button.
|
165 | - `slug` - GitHub slug (username/repo).
|
166 | - `show-count` - Enable displaying the count number.
|
167 |
|
168 | #### `gh-btns-star`
|
169 | ⭐ A star button.
|
170 | - `slug` - GitHub slug (username/repo).
|
171 | - `show-count` - Enable displaying the count number.
|
172 |
|
173 | #### `gh-btns-fork`
|
174 | 🍴 A fork button.
|
175 | - `slug` - GitHub slug (username/repo).
|
176 | - `show-count` - Enable displaying the count number.
|
177 |
|
178 | #### `gh-btns-follow`
|
179 | 👤 A follow button.
|
180 | - `user` - GitHub username.
|
181 | - `show-count` - Enable displaying the count number.
|