Skip to content

Commit 0c7c251

Browse files
Merge pull request #236 from vuejs-translations/72587ebe
test perfops rom script (#235)
2 parents 3b68c35 + a24fbc6 commit 0c7c251

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

.vitepress/config.ts

+16-18
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'
@@ -577,6 +577,17 @@ export const sidebar: ThemeConfig['sidebar'] = {
577577
// const i18n: ThemeConfig['i18n'] = {
578578
// }
579579

580+
function inlineScript(file: string): HeadConfig {
581+
return [
582+
'script',
583+
{},
584+
fs.readFileSync(
585+
path.resolve(__dirname, `./inlined-scripts/${file}`),
586+
'utf-8'
587+
)
588+
]
589+
}
590+
580591
export default defineConfigWithTheme<ThemeConfig>({
581592
extends: baseConfig,
582593

@@ -618,22 +629,8 @@ export default defineConfigWithTheme<ThemeConfig>({
618629
href: 'https://sponsors.vuejs.org'
619630
}
620631
],
621-
[
622-
'script',
623-
{},
624-
fs.readFileSync(
625-
path.resolve(__dirname, './inlined-scripts/restorePreference.js'),
626-
'utf-8'
627-
)
628-
],
629-
[
630-
'script',
631-
{},
632-
fs.readFileSync(
633-
path.resolve(__dirname, './inlined-scripts/uwu.js'),
634-
'utf-8'
635-
)
636-
],
632+
inlineScript('restorePreference.js'),
633+
inlineScript('uwu.js'),
637634
[
638635
'script',
639636
{
@@ -649,7 +646,8 @@ export default defineConfigWithTheme<ThemeConfig>({
649646
src: 'https://vueschool.io/banner.js?affiliate=vuejs&type=top',
650647
async: 'true'
651648
}
652-
]
649+
],
650+
inlineScript('perfops.js')
653651
],
654652

655653
themeConfig: {

.vitepress/inlined-scripts/perfops.js

+9
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

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)