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'
@@ -602,6 +602,17 @@ const i18n: ThemeConfig['i18n'] = {
602602 ariaSidebarNav : 'Навигация в боковой панели' ,
603603}
604604
605+ function inlineScript ( file : string ) : HeadConfig {
606+ return [
607+ 'script' ,
608+ { } ,
609+ fs . readFileSync (
610+ path . resolve ( __dirname , `./inlined-scripts/${ file } ` ) ,
611+ 'utf-8'
612+ )
613+ ]
614+ }
615+
605616export default defineConfigWithTheme < ThemeConfig > ( {
606617 extends : baseConfig ,
607618
@@ -643,22 +654,8 @@ export default defineConfigWithTheme<ThemeConfig>({
643654 href : 'https://automation.vuejs.org'
644655 }
645656 ] ,
646- [
647- 'script' ,
648- { } ,
649- fs . readFileSync (
650- path . resolve ( __dirname , './inlined-scripts/restorePreference.js' ) ,
651- 'utf-8'
652- )
653- ] ,
654- [
655- 'script' ,
656- { } ,
657- fs . readFileSync (
658- path . resolve ( __dirname , './inlined-scripts/uwu.js' ) ,
659- 'utf-8'
660- )
661- ] ,
657+ inlineScript ( 'restorePreference.js' ) ,
658+ inlineScript ( 'uwu.js' ) ,
662659 [
663660 'script' ,
664661 {
@@ -674,7 +671,8 @@ export default defineConfigWithTheme<ThemeConfig>({
674671 src : 'https://vueschool.io/banner.js?affiliate=vuejs&type=top' ,
675672 async : 'true'
676673 }
677- ]
674+ ] ,
675+ inlineScript ( 'perfops.js' )
678676 ] ,
679677
680678 themeConfig : {
0 commit comments