11import fs from 'fs'
22import path from 'path'
3- import { defineConfigWithTheme } from 'vitepress'
3+ import { defineConfigWithTheme , type HeadConfig } from 'vitepress'
44import type { Config as ThemeConfig } from '@vue/theme'
55import baseConfig from '@vue/theme/config'
66import { headerPlugin } from './headerMdPlugin'
@@ -570,6 +570,17 @@ export const sidebar: ThemeConfig['sidebar'] = {
570570// const i18n: ThemeConfig['i18n'] = {
571571// }
572572
573+ function inlineScript ( file : string ) : HeadConfig {
574+ return [
575+ 'script' ,
576+ { } ,
577+ fs . readFileSync (
578+ path . resolve ( __dirname , `./inlined-scripts/${ file } ` ) ,
579+ 'utf-8'
580+ )
581+ ]
582+ }
583+
573584export default defineConfigWithTheme < ThemeConfig > ( {
574585 extends : baseConfig ,
575586
@@ -611,22 +622,8 @@ export default defineConfigWithTheme<ThemeConfig>({
611622 href : 'https://automation.vuejs.org'
612623 }
613624 ] ,
614- [
615- 'script' ,
616- { } ,
617- fs . readFileSync (
618- path . resolve ( __dirname , './inlined-scripts/restorePreference.js' ) ,
619- 'utf-8'
620- )
621- ] ,
622- [
623- 'script' ,
624- { } ,
625- fs . readFileSync (
626- path . resolve ( __dirname , './inlined-scripts/uwu.js' ) ,
627- 'utf-8'
628- )
629- ] ,
625+ inlineScript ( 'restorePreference.js' ) ,
626+ inlineScript ( 'uwu.js' ) ,
630627 [
631628 'script' ,
632629 {
@@ -642,7 +639,8 @@ export default defineConfigWithTheme<ThemeConfig>({
642639 src : 'https://vueschool.io/banner.js?affiliate=vuejs&type=top' ,
643640 async : 'true'
644641 }
645- ]
642+ ] ,
643+ inlineScript ( 'perfops.js' )
646644 ] ,
647645
648646 themeConfig : {
0 commit comments