26 lines
609 B
TypeScript
26 lines
609 B
TypeScript
import type { Plugin } from '@vuepress/core'
|
|
|
|
export interface BaiduTongjiOptions {
|
|
key?: string
|
|
}
|
|
|
|
export function baiduTongjiPlugin({ key = '' }: BaiduTongjiOptions): Plugin {
|
|
return {
|
|
name: '@vuepress-plume/plugin-baidu-tongji',
|
|
extendsPage: (page) => {
|
|
page.frontmatter.head = page.frontmatter.head || []
|
|
page.frontmatter.head?.push([
|
|
'script',
|
|
{
|
|
type: 'text/javascript',
|
|
},
|
|
'var _hmt = _hmt || []',
|
|
])
|
|
page.frontmatter.head?.push([
|
|
'script',
|
|
{ src: `https://hm.baidu.com/hm.js?${key}` },
|
|
])
|
|
},
|
|
}
|
|
}
|