1
1
import fs from 'fs'
2
2
import path from 'path'
3
- import { defineConfigWithTheme } from 'vitepress'
3
+ import { defineConfigWithTheme , type HeadConfig } from 'vitepress'
4
4
import type { Config as ThemeConfig } from '@vue/theme'
5
5
import baseConfig from '@vue/theme/config'
6
6
import { headerPlugin } from './headerMdPlugin'
@@ -570,6 +570,17 @@ export const sidebar: ThemeConfig['sidebar'] = {
570
570
// const i18n: ThemeConfig['i18n'] = {
571
571
// }
572
572
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
+
573
584
export default defineConfigWithTheme < ThemeConfig > ( {
574
585
extends : baseConfig ,
575
586
@@ -611,22 +622,8 @@ export default defineConfigWithTheme<ThemeConfig>({
611
622
href : 'https://automation.vuejs.org'
612
623
}
613
624
] ,
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' ) ,
630
627
[
631
628
'script' ,
632
629
{
@@ -642,7 +639,8 @@ export default defineConfigWithTheme<ThemeConfig>({
642
639
src : 'https://vueschool.io/banner.js?affiliate=vuejs&type=top' ,
643
640
async : 'true'
644
641
}
645
- ]
642
+ ] ,
643
+ inlineScript ( 'perfops.js' )
646
644
] ,
647
645
648
646
themeConfig : {
0 commit comments