-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduction of server side rendering (#838)
* initial introduction of server side rendering * update config spec * ESM cache busting in development with workers * correctly establish body and template support for SSR routes * basic metadata support * frontmatter and graph support * fix lint * basic smoke test case for SSR * fix and clean up specs * basic smoke testing with HTML optimization for server routes * handle pre-rendering for SSR routes * support SSR bundling * full frontmatter support and custom route data for SSR routes * document server rendering * add ssr mode to config docs * clarify serve command in README * ESM path to file interop for windows * rebase fixes * remove demo code
- Loading branch information
1 parent
d67c03c
commit 3230cda
Showing
32 changed files
with
992 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { pathToFileURL } from 'url'; | ||
import { workerData, parentPort } from 'worker_threads'; | ||
|
||
async function executeRouteModule({ modulePath, compilation, route, label, id }) { | ||
const { getTemplate = null, getBody = null, getFrontmatter = null } = await import(pathToFileURL(modulePath)).then(module => module); | ||
const parsedCompilation = JSON.parse(compilation); | ||
const data = { | ||
template: null, | ||
body: null, | ||
frontmatter: null | ||
}; | ||
|
||
if (getTemplate) { | ||
data.template = await getTemplate(parsedCompilation, route); | ||
} | ||
|
||
if (getBody) { | ||
data.body = await getBody(parsedCompilation, route); | ||
} | ||
|
||
if (getFrontmatter) { | ||
data.frontmatter = await getFrontmatter(parsedCompilation, route, label, id); | ||
} | ||
|
||
parentPort.postMessage(data); | ||
} | ||
|
||
executeRouteModule(workerData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.