Skip to content

Commit

Permalink
fix: ssr css and preload links in header
Browse files Browse the repository at this point in the history
  • Loading branch information
aoede3 committed Dec 2, 2024
1 parent 61da363 commit 8f31b98
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @taujs/server

v0.1.4 - 02/12/2024

fix: ssr css and preload links in header

v0.1.3 - 22/22/2024

chore(deps): bump cross-spawn and @changesets/cli
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@taujs/server",
"version": "0.1.3",
"version": "0.1.4",
"description": "taujs | τjs",
"author": "Aoede <[email protected]> (https://www.aoede.uk.net)",
"license": "MIT",
Expand Down
7 changes: 6 additions & 1 deletion src/SSRServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@ export const SSRServer: FastifyPluginAsync<SSRServerOptions> = fp(
const initialDataScript = `<script>window.__INITIAL_DATA__ = ${JSON.stringify(initialDataResolved).replace(/</g, '\\u003c')}</script>`;
const { headContent, appHtml } = await renderSSR(initialDataResolved, req.url, attr?.meta);

let aggregateHeadContent = headContent;

if (ssrManifest) aggregateHeadContent += preloadLinks;
if (manifest) aggregateHeadContent += cssLinks;

const fullHtml = template
.replace(SSRTAG.ssrHead, headContent)
.replace(SSRTAG.ssrHead, aggregateHeadContent)
.replace(SSRTAG.ssrHtml, `${appHtml}${initialDataScript}<script type="module" src="${bootstrapModules}" async=""></script>`);

return reply.status(200).header('Content-Type', 'text/html').send(fullHtml);
Expand Down

0 comments on commit 8f31b98

Please sign in to comment.