File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -172,17 +172,19 @@ function serveRawMarkdown() {
172172 return {
173173 name : "serve-raw-markdown" ,
174174 configureServer ( server : ViteDevServer ) {
175- server . middlewares . use ( ( req : IncomingMessage , res : ServerResponse , next : ( ) => void ) => {
176- if ( ! req . url ?. endsWith ( ".md" ) ) return next ( ) ;
177- const mdxPath = join ( srcDir , req . url . replace ( / \. m d $ / , ".mdx" ) ) ;
178- try {
179- const content = readFileSync ( mdxPath , "utf-8" ) ;
180- res . setHeader ( "Content-Type" , "text/plain; charset=utf-8" ) ;
181- res . end ( content ) ;
182- } catch {
183- next ( ) ;
175+ server . middlewares . use (
176+ ( req : IncomingMessage , res : ServerResponse , next : ( ) => void ) => {
177+ if ( ! req . url ?. endsWith ( ".md" ) ) return next ( ) ;
178+ const mdxPath = join ( srcDir , req . url . replace ( / \. m d $ / , ".mdx" ) ) ;
179+ try {
180+ const content = readFileSync ( mdxPath , "utf-8" ) ;
181+ res . setHeader ( "Content-Type" , "text/plain; charset=utf-8" ) ;
182+ res . end ( content ) ;
183+ } catch {
184+ next ( ) ;
185+ }
184186 }
185- } ) ;
187+ ) ;
186188 } ,
187189 buildStart ( ) {
188190 for ( const file of findMdxFiles ( srcDir ) ) {
You can’t perform that action at this time.
0 commit comments