VuePress站点
小于 1 分钟
VuePress站点添加跟踪代码
修改VuePress项目下的文件
src/.vuepress/config.ts
添加跟踪代码
// Umami 跟踪代码
head: [
['script', { async: true, src: 'https://umami.xxx.com/random-string.js', 'data-website-id': '702f98a8-de52-4298-8f6b-ab6520b2fa9c' }]
完整的示例:
import { defineUserConfig } from "vuepress";
import theme from "./theme.js";
import { searchProPlugin } from "vuepress-plugin-search-pro";
import { componentsPlugin } from "vuepress-plugin-components";
export default defineUserConfig({
base: "/",
lang: "zh-CN",
title: "",
description: "五六零网校知识库",
theme,
// 插件设置
plugins: [
searchProPlugin({
// 索引全部内容
indexContent: true,
// 为分类和标签添加索引
customFields: [
{
getter: (page) => page.frontmatter.category,
formatter: "分类:$content",
},
{
getter: (page) => page.frontmatter.tag,
formatter: "标签:$content",
},
],
}),
componentsPlugin({
components: [
"ArtPlayer",
"AudioPlayer",
"Badge",
"BiliBili",
"CodePen",
"FontIcon",
"PDF",
"Replit",
"Share",
"SiteInfo",
"StackBlitz",
"VPBanner",
"VPCard",
"VidStack",
"VideoPlayer",
"XiGua",
"YouTube",
],
// Enable it with pwa
// shouldPrefetch: false,
}),
],
// Umami 跟踪代码
head: [
['script', { async: true, src: 'https://umami.xxx.com/random-string.js', 'data-website-id': '702f98a8-de52-4298-8f6b-ab6520b2fa9c' }]
],
});