@@ -3,9 +3,8 @@ import { defineConfig } from 'astro/config';
3
3
import starlight from '@astrojs/starlight' ;
4
4
import mtasaStarlightThemePlugin from '@multitheftauto/starlight-theme-mtasa' ;
5
5
import { SITE_TITLE , SITE_URL } from './src/content.constants' ;
6
- import { readFileSync , writeFileSync , mkdirSync , copyFileSync , existsSync } from 'fs' ;
7
- import { join } from 'path' ;
8
-
6
+ import fs from 'fs' ;
7
+ import path from 'path' ;
9
8
10
9
export default defineConfig ( {
11
10
site : SITE_URL ,
@@ -87,7 +86,7 @@ export default defineConfig({
87
86
items : [
88
87
{ label : 'Element types' , link : 'Element' } ,
89
88
{ label : 'Element tree' , link : 'Element_tree' } ,
90
- { label : 'Entities ' , link : 'Entity' } ,
89
+ { label : 'Entity ' , link : 'Entity' } ,
91
90
]
92
91
} ,
93
92
{
@@ -107,45 +106,16 @@ export default defineConfig({
107
106
plugins : [
108
107
{
109
108
name : 'override-pagefind-config' ,
110
- writeBundle : {
111
- sequential : true ,
112
- order : 'post' ,
113
- handler : async ( ) => {
114
- const targetDir = join ( 'dist' , 'pagefind' ) ;
115
- const sourceDir = join ( 'dist' , '_pagefind' ) ;
116
-
117
- if ( ! existsSync ( targetDir ) ) mkdirSync ( targetDir , { recursive : true } ) ;
118
-
119
- const filesToCopy = [ 'pagefind.js' , 'pagefind.json' , 'pagefind-*.wasm' ] ;
120
- filesToCopy . forEach ( pattern => {
121
- try {
122
- const sourcePath = join ( sourceDir , pattern . replace ( '*' , '' ) ) ;
123
- if ( existsSync ( sourcePath ) ) {
124
- copyFileSync (
125
- sourcePath ,
126
- join ( targetDir , pattern . replace ( '*' , '' ) )
127
- ) ;
128
- }
129
- } catch ( error ) {
130
- console . warn ( `Filed to copy ${ pattern } :` , error . message ) ;
131
- }
132
- } ) ;
133
-
134
- const configPath = join ( targetDir , 'pagefind.json' ) ;
135
- if ( existsSync ( configPath ) ) {
136
- const config = JSON . parse ( readFileSync ( configPath , 'utf-8' ) ) ;
137
- config . source = 'pages' ;
138
- writeFileSync ( configPath , JSON . stringify ( config ) ) ;
139
- } else {
140
- writeFileSync ( configPath , JSON . stringify ( {
141
- source : 'pages' ,
142
- bundlePath : '/pagefind/'
143
- } ) ) ;
144
-
145
- }
109
+ closeBundle : async ( ) => {
110
+ const configPath = path . join ( 'dist' , 'pagefind' , 'pagefind.json' ) ;
111
+
112
+ if ( fs . existsSync ( configPath ) ) {
113
+ let config = JSON . parse ( fs . readFileSync ( configPath , 'utf-8' ) ) ;
114
+ config . source = 'pages' ;
115
+ fs . writeFileSync ( configPath , JSON . stringify ( config ) ) ;
146
116
}
147
- }
148
- }
149
- ]
117
+ } ,
118
+ } ,
119
+ ] ,
150
120
}
151
121
} ) ;
0 commit comments