Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sapling/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@sapling/sapling",
"description": "A micro SSR framework",
"license": "MIT",
"version": "0.3.1",
"version": "0.4.0",
"imports": {
"@std/media-types": "jsr:@std/media-types@^1.1.0",
"@std/path": "jsr:@std/path@^1.0.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/sapling/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const SAPLING_VERSION = "0.3.1";
export const SAPLING_VERSION = "0.4.0";
19 changes: 19 additions & 0 deletions packages/sapling/src/sapling-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SAPLING_VERSION } from "./constants.ts";
* @param props.children - The content to render in the body of the page
* @param props.stream - When true, returns a ReadableStream to stream the HTML output. Defaults to false
* @param props.disableUnoCSS - When true, skips UnoCSS generation
* @param props.enableIslands - When true, adds the islands script and CSS
*
* @example
* ```ts
Expand Down Expand Up @@ -78,6 +79,15 @@ export function Layout(props: LayoutProps): Promise<string> | ReadableStream {
<style>${css.css}</style>`
: ``
}
${
props.enableIslands
? `
<!-- Sapling Islands -->
<script type="module" src="https://sapling-is.land"></script>
<style>sapling-island{display:contents}</style>
`
: ``
}
${props.head}
</head>
${props.bodyClass ? `<body class="${props.bodyClass}">` : `<body>`}
Expand Down Expand Up @@ -117,6 +127,15 @@ export function Layout(props: LayoutProps): Promise<string> | ReadableStream {
<style>${css.css}</style>`
: ``
}
${
props.enableIslands
? `
<!-- Sapling Islands -->
<script type="module" src="https://sapling-is.land"></script>
<style>sapling-island{display:contents}</style>
`
: ``
}
${props.head}`
)
);
Expand Down
9 changes: 8 additions & 1 deletion packages/sapling/src/sapling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,17 @@ export class Sapling {
/**
* Generate pre-rendered HTML files for registered routes
* @param outputDir - The directory to output the HTML files
* @returns {Promise<void>} A promise that resolves when all files have been generated
* @example
* ```ts
* // Generate pre-rendered pages in the dist directory
* await site.buildPrerenderRoutes("dist");
* await site.buildPrerenderRoutes("./dist");
*
* // You can also use a relative path
* await site.buildPrerenderRoutes("../dist");
*
* // Or an absolute path
* await site.buildPrerenderRoutes("/var/www/html");
* ```
*/
async buildPrerenderRoutes(outputDir: string): Promise<void> {
Expand Down
4 changes: 4 additions & 0 deletions packages/sapling/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export interface LayoutProps {
* Whether to disable the tailwind reset
*/
disableTailwindReset?: boolean;
/**
* Whether to enable Sapling Islands functionality
*/
enableIslands?: boolean;
/**
* The head content
*/
Expand Down