2023-12-27 02:18:19 +08:00

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}` },
])
},
}
}