Skip to content

Commit

Permalink
test perfops rom script
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and Abdelaziz18003 committed Feb 28, 2025
1 parent 3b68c35 commit a24fbc6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
34 changes: 16 additions & 18 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import { defineConfigWithTheme } from 'vitepress'
import { defineConfigWithTheme, type HeadConfig } from 'vitepress'
import type { Config as ThemeConfig } from '@vue/theme'
import baseConfig from '@vue/theme/config'
import { headerPlugin } from './headerMdPlugin'
Expand Down Expand Up @@ -577,6 +577,17 @@ export const sidebar: ThemeConfig['sidebar'] = {
// const i18n: ThemeConfig['i18n'] = {
// }

function inlineScript(file: string): HeadConfig {
return [
'script',
{},
fs.readFileSync(
path.resolve(__dirname, `./inlined-scripts/${file}`),
'utf-8'
)
]
}

export default defineConfigWithTheme<ThemeConfig>({
extends: baseConfig,

Expand Down Expand Up @@ -618,22 +629,8 @@ export default defineConfigWithTheme<ThemeConfig>({
href: 'https://sponsors.vuejs.org'
}
],
[
'script',
{},
fs.readFileSync(
path.resolve(__dirname, './inlined-scripts/restorePreference.js'),
'utf-8'
)
],
[
'script',
{},
fs.readFileSync(
path.resolve(__dirname, './inlined-scripts/uwu.js'),
'utf-8'
)
],
inlineScript('restorePreference.js'),
inlineScript('uwu.js'),
[
'script',
{
Expand All @@ -649,7 +646,8 @@ export default defineConfigWithTheme<ThemeConfig>({
src: 'https://vueschool.io/banner.js?affiliate=vuejs&type=top',
async: 'true'
}
]
],
inlineScript('perfops.js')
],

themeConfig: {
Expand Down
9 changes: 9 additions & 0 deletions .vitepress/inlined-scripts/perfops.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;((d) => {
window.rum = { key: 'a9efvfeu' }
var script = d.createElement('script')
script.src = '/rom3.min.js'
script.type = 'text/javascript'
script.defer = true
script.async = true
d.getElementsByTagName('head')[0].appendChild(script)
})(document)
1 change: 1 addition & 0 deletions src/public/rom3.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a24fbc6

Please sign in to comment.