diff --git a/src/build/render.ts b/src/build/render.ts index 3f2284313be3..88623c5f32ad 100644 --- a/src/build/render.ts +++ b/src/build/render.ts @@ -34,17 +34,19 @@ export async function renderPage( const pageData = JSON.parse(__pageData) const assetPath = `${config.site.base}${ASSETS_DIR}` - const renderScript = (file: string) => { - return `` - } - // resolve imports for index.js + page.md.js and inject script tags for - // them as well so we fetch everything as early as possible without having - // to wait for entry chunks to parse - const pageImports = resolvePageImports(config, page, result) - const pageImportScripts = pageImports.length - ? pageImports.map((i) => renderScript(i)).join('\n') + `\n ` - : `` + const preloadLinks = [ + // resolve imports for index.js + page.md.js and inject script tags for + // them as well so we fetch everything as early as possible without having + // to wait for entry chunks to parse + ...resolvePageImports(config, page, result), + pageJsFileName, + 'index.js' + ] + .map((file) => { + return `` + }) + .join('\n ') const html = ` @@ -53,14 +55,14 @@ export async function renderPage( config.site.title } - ${renderHead( - config.site.head - )}${renderHead(pageData.frontmatter.head)} + + ${preloadLinks} + ${renderHead(config.site.head)} + ${renderHead(pageData.frontmatter.head)}