Compare commits

..
3 Commits
Author SHA1 Message Date
qingwei.li 5b25e7daca -> v2.2.0 2017-02-09 22:17:29 +08:00
qingwei.li a4bd5fd295 bump: 2.2.0 2017-02-09 22:17:23 +08:00
cinwell.liandGitHub ac61bb0e75 feat(plugins): add Google Analytics plugin (#66) 2017-02-09 22:16:15 +08:00
13 changed files with 152 additions and 8 deletions
+5
View File
@@ -1,3 +1,8 @@
## 2.2.0
### Features
- Add `Google Analytics` plugin.
## 2.1.0
### Features
- Add search plugin
+1 -2
View File
@@ -76,13 +76,12 @@ These open-source projects are using docsify to generate their sites. Pull reque
## Development
### prepare
```bash
npm i && npm run dev
open http://localhost:3000
```
### More Language Highlight
## More Language Highlight
```html
<script src="//unpkg.com/docsify"></script>
+11
View File
@@ -47,3 +47,14 @@ isProd && build({
moduleName: 'D.Search',
plugins: [uglify()]
})
build({
entry: 'plugins/ga.js',
output: 'plugins/ga.js',
moduleName: 'D.GA'
})
isProd && build({
entry: 'plugins/ga.js',
output: 'plugins/ga.min.js',
moduleName: 'D.GA',
plugins: [uglify()]
})
+18 -1
View File
@@ -468,7 +468,7 @@ If a document can have a search, can enhance some user experience. Installing th
```html
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
<script src="//unpkg.com/docsify"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.js"></script>
```
@@ -495,3 +495,20 @@ window.$docsify = {
}
}
```
### Google Analytics
Install the plugin and configure the track id.
```html
<script src="//unpkg.com/docsify" data-ga="UA-XXXXX-Y"></script>
<script src="//unpkg.com/docsify/lib/plugins/ga.js"></script>
```
or
```js
window.$docsify = {
ga: 'UA-XXXXX-Y'
}
```
+1 -1
View File
@@ -1,6 +1,6 @@
![logo](_media/icon.svg)
# docsify <small>2.1.0</small>
# docsify <small>2.2.0</small>
> A magical documentation site generator.
+17
View File
@@ -501,3 +501,20 @@ window.$docsify = {
}
}
```
### Google Analytics
安装插件并且配置 track id。
```html
<script src="//unpkg.com/docsify" data-ga="UA-XXXXX-Y"></script>
<script src="//unpkg.com/docsify/lib/plugins/ga.js"></script>
```
或者
```js
window.$docsify = {
ga: 'UA-XXXXX-Y'
}
```
+2 -1
View File
@@ -2799,7 +2799,8 @@ var OPTIONS = merge({
auto2top: false,
name: '',
themeColor: '',
nameLink: window.location.pathname
nameLink: window.location.pathname,
ga: ''
}, window.$docsify);
var script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop();
+1 -1
View File
File diff suppressed because one or more lines are too long
+50
View File
@@ -0,0 +1,50 @@
this.D = this.D || {};
this.D.GA = (function () {
'use strict';
// From https://github.com/egoist/vue-ga/blob/master/src/index.js
function appendScript () {
var script = document.createElement('script');
script.async = true;
script.src = 'https://www.google-analytics.com/analytics.js';
document.body.appendChild(script);
}
function init (id) {
if (!window.ga) {
appendScript();
window.ga = window.ga || function () {
(window.ga.q = window.ga.q || []).push(arguments);
};
window.ga.l = Number(new Date());
window.ga('create', id, 'auto');
}
}
function collect () {
init(window.$docsify.ga);
window.ga('set', 'page', location.href);
window.ga('send', 'pageview');
}
var install = function () {
if (!window.Docsify || !window.Docsify.installed) {
console.error('[Docsify] Please load docsify.js first.');
return
}
if (!window.$docsify.ga) {
console.error('[Docsify] ga is required.');
return
}
collect();
window.$docsify.plugins = [].concat(window.$docsify.plugins, collect);
};
var ga = install();
return ga;
}());
+1
View File
@@ -0,0 +1 @@
this.D=this.D||{},this.D.GA=function(){"use strict";function o(){var o=document.createElement("script");o.async=!0,o.src="https://www.google-analytics.com/analytics.js",document.body.appendChild(o)}function i(i){window.ga||(o(),window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=Number(new Date),window.ga("create",i,"auto"))}function n(){i(window.$docsify.ga),window.ga("set","page",location.href),window.ga("send","pageview")}var w=function(){return window.Docsify&&window.Docsify.installed?window.$docsify.ga?(n(),void(window.$docsify.plugins=[].concat(window.$docsify.plugins,n))):void console.error("[Docsify] ga is required."):void console.error("[Docsify] Please load docsify.js first.")},s=w();return s}();
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "2.1.0",
"version": "2.2.0",
"description": "A magical documentation generator.",
"main": "lib/docsify.js",
"files": [
+2 -1
View File
@@ -15,7 +15,8 @@ const OPTIONS = utils.merge({
auto2top: false,
name: '',
themeColor: '',
nameLink: window.location.pathname
nameLink: window.location.pathname,
ga: ''
}, window.$docsify)
const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop()
+42
View File
@@ -0,0 +1,42 @@
// From https://github.com/egoist/vue-ga/blob/master/src/index.js
function appendScript () {
const script = document.createElement('script')
script.async = true
script.src = 'https://www.google-analytics.com/analytics.js'
document.body.appendChild(script)
}
function init (id) {
if (!window.ga) {
appendScript()
window.ga = window.ga || function () {
(window.ga.q = window.ga.q || []).push(arguments)
}
window.ga.l = Number(new Date())
window.ga('create', id, 'auto')
}
}
function collect () {
init(window.$docsify.ga)
window.ga('set', 'page', location.href)
window.ga('send', 'pageview')
}
const install = function () {
if (!window.Docsify || !window.Docsify.installed) {
console.error('[Docsify] Please load docsify.js first.')
return
}
if (!window.$docsify.ga) {
console.error('[Docsify] ga is required.')
return
}
collect()
window.$docsify.plugins = [].concat(window.$docsify.plugins, collect)
}
export default install()