Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test perfops rom script (#235) #236

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.