Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
计算机应用开发
前端
Vuepress
提交
397d01a5
V
Vuepress
项目概览
计算机应用开发
/
前端
/
Vuepress
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vuepress
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
397d01a5
编写于
8月 12, 2018
作者:
U
ULIVZ
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: init @vuepress/plugin-google-analytics
上级
1c170c22
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
88 addition
and
27 deletion
+88
-27
packages/@vuepress/core/lib/app/clientEntry.js
packages/@vuepress/core/lib/app/clientEntry.js
+0
-25
packages/@vuepress/core/lib/webpack/createBaseConfig.js
packages/@vuepress/core/lib/webpack/createBaseConfig.js
+0
-1
packages/@vuepress/plugin-google-analytics/.npmignore
packages/@vuepress/plugin-google-analytics/.npmignore
+2
-0
packages/@vuepress/plugin-google-analytics/README.md
packages/@vuepress/plugin-google-analytics/README.md
+6
-0
packages/@vuepress/plugin-google-analytics/index.js
packages/@vuepress/plugin-google-analytics/index.js
+23
-0
packages/@vuepress/plugin-google-analytics/inject.js
packages/@vuepress/plugin-google-analytics/inject.js
+28
-0
packages/@vuepress/plugin-google-analytics/package.json
packages/@vuepress/plugin-google-analytics/package.json
+25
-0
packages/@vuepress/theme-default/index.js
packages/@vuepress/theme-default/index.js
+3
-1
packages/@vuepress/theme-default/package.json
packages/@vuepress/theme-default/package.json
+1
-0
未找到文件。
packages/@vuepress/core/lib/app/clientEntry.js
浏览文件 @
397d01a5
...
...
@@ -11,31 +11,6 @@ window.__VUEPRESS_VERSION__ = {
hash
:
LAST_COMMIT_HASH
}
// TODO Separate it into a plugin ('vuepress-plugin-ga')
// Google analytics integration
if
(
process
.
env
.
NODE_ENV
===
'
production
'
&&
GA_ID
)
{
(
function
(
i
,
s
,
o
,
g
,
r
,
a
,
m
)
{
i
[
'
GoogleAnalyticsObject
'
]
=
r
i
[
r
]
=
i
[
r
]
||
function
()
{
(
i
[
r
].
q
=
i
[
r
].
q
||
[]).
push
(
arguments
)
}
i
[
r
].
l
=
1
*
new
Date
()
a
=
s
.
createElement
(
o
)
m
=
s
.
getElementsByTagName
(
o
)[
0
]
a
.
async
=
1
a
.
src
=
g
m
.
parentNode
.
insertBefore
(
a
,
m
)
})(
window
,
document
,
'
script
'
,
'
https://www.google-analytics.com/analytics.js
'
,
'
ga
'
)
ga
(
'
create
'
,
GA_ID
,
'
auto
'
)
ga
(
'
send
'
,
'
pageview
'
)
router
.
afterEach
(
function
(
to
)
{
ga
(
'
set
'
,
'
page
'
,
to
.
fullPath
)
ga
(
'
send
'
,
'
pageview
'
)
})
}
router
.
onReady
(()
=>
{
app
.
$mount
(
'
#app
'
)
...
...
packages/@vuepress/core/lib/webpack/createBaseConfig.js
浏览文件 @
397d01a5
...
...
@@ -278,7 +278,6 @@ module.exports = function createBaseConfig ({
.
plugin
(
'
injections
'
)
.
use
(
require
(
'
webpack/lib/DefinePlugin
'
),
[{
BASE_URL
:
JSON
.
stringify
(
siteConfig
.
base
||
'
/
'
),
GA_ID
:
siteConfig
.
ga
?
JSON
.
stringify
(
siteConfig
.
ga
)
:
false
,
SW_ENABLED
:
!!
siteConfig
.
serviceWorker
,
VUEPRESS_VERSION
:
JSON
.
stringify
(
require
(
'
../../package.json
'
).
version
),
LAST_COMMIT_HASH
:
JSON
.
stringify
(
getLastCommitHash
())
...
...
packages/@vuepress/plugin-google-analytics/.npmignore
0 → 100644
浏览文件 @
397d01a5
__tests__
__mocks__
\ No newline at end of file
packages/@vuepress/plugin-google-analytics/README.md
0 → 100644
浏览文件 @
397d01a5
# @vuepress/plugin-google-analytics
> google-analytics plugin for vuepress
## Options
packages/@vuepress/plugin-google-analytics/index.js
0 → 100644
浏览文件 @
397d01a5
const
path
=
require
(
'
path
'
)
module
.
exports
=
(
options
=
{},
context
)
=>
({
name
:
'
google-analytics
'
,
ready
()
{
const
{
siteConfig
=
{}}
=
context
const
ga
=
options
.
ga
||
siteConfig
.
ga
context
.
GA_ID
=
ga
?
JSON
.
stringify
(
ga
)
:
false
},
chainWebpack
(
config
)
{
config
.
plugin
(
'
injections
'
).
tap
(([
options
])
=>
[
Object
.
assign
(
options
,
{
GA_ID
:
context
.
GA_ID
})
])
},
enhanceAppFiles
:
[
path
.
resolve
(
__dirname
,
'
inject.js
'
)
]
})
packages/@vuepress/plugin-google-analytics/inject.js
0 → 100644
浏览文件 @
397d01a5
/* global GA_ID, ga */
export
default
({
router
})
=>
{
// Google analytics integration
if
(
process
.
env
.
NODE_ENV
===
'
production
'
&&
GA_ID
)
{
(
function
(
i
,
s
,
o
,
g
,
r
,
a
,
m
)
{
i
[
'
GoogleAnalyticsObject
'
]
=
r
i
[
r
]
=
i
[
r
]
||
function
()
{
(
i
[
r
].
q
=
i
[
r
].
q
||
[]).
push
(
arguments
)
}
i
[
r
].
l
=
1
*
new
Date
()
a
=
s
.
createElement
(
o
)
m
=
s
.
getElementsByTagName
(
o
)[
0
]
a
.
async
=
1
a
.
src
=
g
m
.
parentNode
.
insertBefore
(
a
,
m
)
})(
window
,
document
,
'
script
'
,
'
https://www.google-analytics.com/analytics.js
'
,
'
ga
'
)
ga
(
'
create
'
,
GA_ID
,
'
auto
'
)
ga
(
'
send
'
,
'
pageview
'
)
router
.
afterEach
(
function
(
to
)
{
ga
(
'
set
'
,
'
page
'
,
to
.
fullPath
)
ga
(
'
send
'
,
'
pageview
'
)
})
}
}
packages/@vuepress/plugin-google-analytics/package.json
0 → 100644
浏览文件 @
397d01a5
{
"name"
:
"@vuepress/plugin-google-analytics"
,
"version"
:
"1.0.0"
,
"description"
:
"google-analytics plugin for vuepress"
,
"main"
:
"index.js"
,
"publishConfig"
:
{
"access"
:
"public"
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git+https://github.com/vuejs/vuepress.git"
},
"keywords"
:
[
"documentation"
,
"vue"
,
"vuepress"
,
"generator"
],
"author"
:
"Evan You"
,
"license"
:
"MIT"
,
"bugs"
:
{
"url"
:
"https://github.com/vuejs/vuepress/issues"
},
"homepage"
:
"https://github.com/vuejs/vuepress/packages/@vuepress/plugin-google-analytics#readme"
}
\ No newline at end of file
packages/@vuepress/theme-default/index.js
浏览文件 @
397d01a5
const
path
=
require
(
'
path
'
)
const
themePlugin
=
require
(
'
./plugin
'
)
const
activeHeaderLinksPlugin
=
require
(
'
@vuepress/plugin-active-header-links
'
)
const
googleAnalyticsPlugin
=
require
(
'
@vuepress/plugin-google-analytics
'
)
// Theme API.
module
.
exports
=
{
...
...
@@ -8,6 +9,7 @@ module.exports = {
notFound
:
path
.
resolve
(
__dirname
,
'
src/NotFound.vue
'
),
plugins
:
[
themePlugin
,
activeHeaderLinksPlugin
activeHeaderLinksPlugin
,
googleAnalyticsPlugin
]
}
packages/@vuepress/theme-default/package.json
浏览文件 @
397d01a5
...
...
@@ -24,6 +24,7 @@
"homepage"
:
"https://github.com/vuejs/vuepress/packages/@vuepress/theme-default#readme"
,
"dependencies"
:
{
"@vuepress/plugin-active-header-links"
:
"1.0.0"
,
"@vuepress/plugin-google-analytics"
:
"1.0.0"
,
"docsearch.js"
:
"^2.5.2"
,
"nprogress"
:
"^0.2.0"
,
"stylus"
:
"^0.54.5"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录