@@ -34,35 +34,38 @@ export default ({ route, publicPath, entrypoints }: RenderParams) => {
3434 throw new Error ( 'No assets!' ) ;
3535 }
3636
37- const cssAssets = assets
38- . filter ( ( asset ) => asset . name . endsWith ( '.css' ) )
39- . map (
40- ( asset ) =>
41- `<link rel="stylesheet" href="${ assetPath ( asset . name ) } "></link>` ,
42- ) ;
43- const jsAssets = assets
44- . filter ( ( asset ) => asset . name . endsWith ( '.js' ) )
45- . map ( ( asset ) => `<script src="${ assetPath ( asset . name ) } "></script>` ) ;
37+ const cssAssets = assets . filter ( ( asset ) => asset . name . endsWith ( '.css' ) ) ;
38+ const jsAssets = assets . filter ( ( asset ) => asset . name . endsWith ( '.js' ) ) ;
4639
4740 const headTags : HeadTags = [ ] ;
4841 const html = render ( route , headTags ) ;
4942
5043 const favicon = ( size ?: number ) =>
5144 `<link rel="icon" type="image/png" ${
5245 size ? `sizes="${ size } x${ size } " ` : ''
53- } href="${ assetPath ( `favicon${ size ? `-${ size } x${ size } ` : '' } .png ` ) } " / >`;
46+ } href="${ assetPath ( `favicon${ size ? `-${ size } x${ size } .png ` : '.ico' } ` ) } ">`;
5447
5548 const shareImageUrl = fullyQualifiedUrl ( assetPath ( 'og-image.png' ) ) ;
5649
57- return `<html>
50+ return `
51+ <!DOCTYPE html>
52+ <html lang="en">
5853 <head>
5954 <script>
6055 ((d)=>{try{var p=localStorage.getItem('${ themeKey } ');if(p==d||(p!='${ lightMode } '&&matchMedia('(prefers-color-scheme:dark)').matches)) document.documentElement.classList.add(d)}catch(e){}})('${ darkMode } ')
6156 </script>
6257 <link href="https://fonts.googleapis.com/css?family=Shrikhand&display=swap" rel="stylesheet">
6358 <link href="https://fonts.googleapis.com/css?family=DM+Sans&display=swap" rel="stylesheet">
6459 <link href="https://www.monolisa.dev/api/fonts/initial" rel="stylesheet">
65- ${ cssAssets . join ( '\n' ) }
60+ ${ cssAssets
61+ . map ( ( { name } ) => `<link rel="stylesheet" href="${ assetPath ( name ) } ">` )
62+ . join ( '\n' ) }
63+ ${ jsAssets
64+ . map (
65+ ( { name } ) =>
66+ `<link rel="preload" as="script" href="${ assetPath ( name ) } ">` ,
67+ )
68+ . join ( '\n' ) }
6669 ${ renderToString ( < Fragment > { headTags } </ Fragment > ) }
6770 <meta name="viewport" content="width=device-width, initial-scale=1">
6871 <meta name="theme-color" content="#fff"/>
@@ -84,7 +87,9 @@ export default ({ route, publicPath, entrypoints }: RenderParams) => {
8487 </head>
8588 <body>
8689 <div id="app">${ html } </div>
87- ${ jsAssets . join ( '\n' ) }
90+ ${ jsAssets
91+ . map ( ( { name } ) => `<script async src="${ assetPath ( name ) } "></script>` )
92+ . join ( '\n' ) }
8893 </body>
8994 </html>` ;
9095} ;
0 commit comments