Skip to content

Commit 34830ac

Browse files
authored
test perfops rom script (#2524)
1 parent 698ba52 commit 34830ac

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

.vitepress/config.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs'
22
import path from 'path'
3-
import { defineConfigWithTheme } from 'vitepress'
3+
import { defineConfigWithTheme, type HeadConfig } from 'vitepress'
44
import type { Config as ThemeConfig } from '@vue/theme'
55
import baseConfig from '@vue/theme/config'
66
import { headerPlugin } from './headerMdPlugin'
@@ -605,6 +605,17 @@ const i18n: ThemeConfig['i18n'] = {
605605
ariaSidebarNav: 'サイドバー・ナビゲーション',
606606
}
607607

608+
function inlineScript(file: string): HeadConfig {
609+
return [
610+
'script',
611+
{},
612+
fs.readFileSync(
613+
path.resolve(__dirname, `./inlined-scripts/${file}`),
614+
'utf-8'
615+
)
616+
]
617+
}
618+
608619
export default defineConfigWithTheme<ThemeConfig>({
609620
extends: baseConfig,
610621

@@ -646,22 +657,8 @@ export default defineConfigWithTheme<ThemeConfig>({
646657
href: 'https://automation.vuejs.org'
647658
}
648659
],
649-
[
650-
'script',
651-
{},
652-
fs.readFileSync(
653-
path.resolve(__dirname, './inlined-scripts/restorePreference.js'),
654-
'utf-8'
655-
)
656-
],
657-
[
658-
'script',
659-
{},
660-
fs.readFileSync(
661-
path.resolve(__dirname, './inlined-scripts/uwu.js'),
662-
'utf-8'
663-
)
664-
],
660+
inlineScript('restorePreference.js'),
661+
inlineScript('uwu.js'),
665662
[
666663
'script',
667664
{
@@ -677,7 +674,8 @@ export default defineConfigWithTheme<ThemeConfig>({
677674
src: 'https://vueschool.io/banner.js?affiliate=vuejs&type=top',
678675
async: 'true'
679676
}
680-
]
677+
],
678+
inlineScript('perfops.js')
681679
],
682680

683681
themeConfig: {

.vitepress/inlined-scripts/perfops.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;((d) => {
2+
window.rum = { key: 'a9efvfeu' }
3+
var script = d.createElement('script')
4+
script.src = '/rom3.min.js'
5+
script.type = 'text/javascript'
6+
script.defer = true
7+
script.async = true
8+
d.getElementsByTagName('head')[0].appendChild(script)
9+
})(document)

src/public/rom3.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)