refactor!: remove plugin-baidu-tongji
This commit is contained in:
parent
2178a55ca0
commit
d11bf77403
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2021 - PRESENT by pengzhanbo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@ -1,30 +0,0 @@
|
||||
# `@vuepress-plume/plugin-baidu-tongji`
|
||||
|
||||
在vuepress中接入百度统计
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install @vuepress-plume/plugin-baidu-tongji
|
||||
# or
|
||||
pnpm add @vuepress-plume/plugin-baidu-tongji
|
||||
# or
|
||||
yarn add @vuepress-plume/plugin-baidu-tongji
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
// .vuepress/config.[jt]s
|
||||
import { baiduTongjiPlugin } from '@vuepress-plume/plugin-baidu-tongji'
|
||||
|
||||
export default {
|
||||
// ...
|
||||
plugins: [
|
||||
baiduTongjiPlugin({
|
||||
key: '', // 百度统计使用的 key
|
||||
})
|
||||
]
|
||||
// ...
|
||||
}
|
||||
```
|
||||
@ -1,47 +0,0 @@
|
||||
{
|
||||
"name": "@vuepress-plume/plugin-baidu-tongji",
|
||||
"type": "module",
|
||||
"version": "1.0.0-rc.80",
|
||||
"description": "The Plugin for VuePress 2 - baidu tongji",
|
||||
"author": "pengzhanbo <volodymyr@foxmail.com> (https://github.com/pengzhanbo/)",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pengzhanbo/vuepress-theme-plume.git",
|
||||
"directory": "plugins/plugin-baidu-tongji"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pengzhanbo/vuepress-theme-plume/issues"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/node/index.d.ts",
|
||||
"import": "./lib/node/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "lib/node/index.js",
|
||||
"types": "./lib/node/index.d.ts",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "pnpm run copy && pnpm run ts",
|
||||
"clean": "rimraf --glob ./lib ./*.tsbuildinfo",
|
||||
"copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png}\" lib",
|
||||
"ts": "tsc -b tsconfig.build.json"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vuepress": "2.0.0-rc.14"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"keyword": [
|
||||
"VuePress",
|
||||
"vuepress plugin",
|
||||
"baiduTongji",
|
||||
"vuepress-plugin-baidu-tongji"
|
||||
]
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
import { watch } from 'vue'
|
||||
import { usePageData } from 'vuepress/client'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
_hmt?: [name: string, options: any][]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add baidu analytics to the site
|
||||
*
|
||||
* @see https://tongji.baidu.com/
|
||||
* @see https://tongji.baidu.com/holmes/Analytics/%E7%99%BE%E5%BA%A6%E7%BB%9F%E8%AE%A1%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C
|
||||
* @see https://tongji.baidu.com/holmes/Analytics/%E6%8A%80%E6%9C%AF%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97/JS%20API/JS%20API%E6%8A%80%E6%9C%AF%E6%96%87%E6%A1%A3/_trackPageview
|
||||
*/
|
||||
export function useBaiduTongji(): void {
|
||||
if (!window._hmt)
|
||||
return
|
||||
|
||||
const page = usePageData()
|
||||
|
||||
watch(
|
||||
() => page.value.path,
|
||||
(newLocation) => {
|
||||
window._hmt?.push(['_trackPageview', newLocation])
|
||||
},
|
||||
)
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
import { defineClientConfig } from 'vuepress/client'
|
||||
import type { ClientConfig } from 'vuepress/client'
|
||||
import { useBaiduTongji } from './composables/index.js'
|
||||
|
||||
declare const __VUEPRESS_SSR__: boolean
|
||||
|
||||
export default defineClientConfig({
|
||||
setup() {
|
||||
if (__VUEPRESS_SSR__)
|
||||
return
|
||||
|
||||
useBaiduTongji()
|
||||
},
|
||||
}) as ClientConfig
|
||||
@ -1,5 +0,0 @@
|
||||
import { baiduTongjiPlugin } from './plugin.js'
|
||||
|
||||
export * from './plugin.js'
|
||||
|
||||
export default baiduTongjiPlugin
|
||||
@ -1,36 +0,0 @@
|
||||
import type { Plugin, PluginObject } from 'vuepress/core'
|
||||
import { getDirname, path } from 'vuepress/utils'
|
||||
|
||||
export interface BaiduTongjiOptions {
|
||||
key?: string
|
||||
}
|
||||
|
||||
const __dirname = getDirname(import.meta.url)
|
||||
|
||||
export function baiduTongjiPlugin({ key = '' }: BaiduTongjiOptions): Plugin {
|
||||
return (app) => {
|
||||
const plugin: PluginObject = {
|
||||
name: '@vuepress-plume/plugin-baidu-tongji',
|
||||
}
|
||||
|
||||
if (app.env.isDev)
|
||||
return plugin
|
||||
|
||||
return {
|
||||
...plugin,
|
||||
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
|
||||
extendsPage: (page) => {
|
||||
page.frontmatter.head ??= []
|
||||
page.frontmatter.head?.push([
|
||||
'script',
|
||||
{ type: 'text/javascript' },
|
||||
'window._hmt = window._hmt || []',
|
||||
])
|
||||
page.frontmatter.head?.push([
|
||||
'script',
|
||||
{ src: `https://hm.baidu.com/hm.js?${key}`, async: true },
|
||||
])
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib"
|
||||
},
|
||||
"files": [],
|
||||
"include": ["./src"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user