You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 357b79a
Browse filesBrowse the repository at this point in the historyBrowse files
Under Node, code that calls a Bun API failed with "Bun is not defined"
and no way forward. Each such error now says to run bongo with Bun, in
the CLI, the terminal, and the dev overlay.
A partial that called such code was told to add {{#expect Bun}}. A
partial now gets that advice only for a name in its own source.
Copy file name to clipboardExpand all lines: docs/content/cli.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,14 +55,14 @@ An unknown option, or a `--port` that is not a port number, stops the command wi
55
55
56
56
## Run with Bun
57
57
58
-
The `bongo` command starts with Node. Image processing needs Bun, so run the command through Bun to resize images:
58
+
The `bongo` command starts with Node. Image processing needs Bun. So does your own code when it calls a Bun API, such as `Bun.markdown` in a `$utils` function or in the config. Run the command through Bun for either one:
59
59
60
60
```sh
61
61
bunx --bun bongo build
62
62
bun --bun run build # for a "build": "bongo build" script
63
63
```
64
64
65
-
See [Images](/images/#bun-runtime).
65
+
Under Node, code that calls a Bun API fails the build, and the error says to run bongo with Bun. See [Images](/images/#bun-runtime).
Copy file name to clipboardExpand all lines: docs/content/quick-start.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ bun run build
32
32
```
33
33
34
34
<bongo:note>
35
-
The `bongo` command starts with Node, and image processing needs Bun. To resize images, run the scripts through Bun: `bun --bun run dev` and `bun --bun run build`. See [Images](/images/#bun-runtime).
35
+
The `bongo` command starts with Node. Image processing needs Bun, and so does your own code when it calls a Bun API, such as `Bun.markdown`. For either one, run the scripts through Bun: `bun --bun run dev` and `bun --bun run build`. See [Images](/images/#bun-runtime).
Copy file name to clipboardExpand all lines: packages/bongo/readme.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -493,7 +493,7 @@ Each attribute after `src` is an argument. A value is a quoted string, a bare va
493
493
494
494
A partial in `partials/` gets its arguments, the config values (`$site`, `$utils`, `$data`, `$assets`), and the `$page`, `$pages`, `$section`, and `$tags` of the page that renders it. An argument with the same name wins: `{{#partial src="postmeta" $page=post}}`. A `$partials` function gets only its arguments. A partial that a Markdown element or a loader calls runs when the content file loads, before any page renders, so it gets no page values.
495
495
496
-
A `.hbs` partial declares the arguments that it reads with `{{#expect title, date}}`. `$slot`, the inner HTML of a Markdown element, is always declared. A partial that reads a name it does not declare fails the build with `partials/card.hbs reads "title", but does not declare it. Add {{#expect title}} at the top of the partial.`
496
+
A `.hbs` partial declares the arguments that it reads with `{{#expect title, date}}`. `$slot`, the inner HTML of a Markdown element, is always declared. A partial that reads a name it does not declare fails the build with `partials/card.hbs reads "title", but does not declare it; add {{#expect title}} at the top of the partial`.
497
497
498
498
## Template Variables
499
499
@@ -615,6 +615,8 @@ bun --bun run build # for a "build": "bongo build" script
615
615
616
616
Under Node, bongo copies each image as it is, under a hashed name, and prints one notice for each build. The build does not fail. It adds `width` and `height` only to SVG and GIF images.
617
617
618
+
Your own code needs Bun too when it calls a Bun API, such as `Bun.markdown` in a `$utils` function or in the config. Under Node, such code fails the build, and the error says to run bongo with Bun.
619
+
618
620
JPEG, PNG, and WebP files are encoded with the same codecs on every platform, so a build makes the same bytes on macOS, Linux, and Windows.
619
621
620
622
bongo adds `width` and `height` to images. If your CSS limits the width of images, also give them `height: auto`, so they keep their aspect ratio:
Copy file name to clipboardExpand all lines: packages/bongo/src/build.test.ts
+17-1Lines changed: 17 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -896,7 +896,23 @@ describe('partials', () => {
896
896
'content/index.html': '',
897
897
});
898
898
try{
899
-
awaitexpect(build({cwd: root})).rejects.toThrow('partials/blog/meta.hbs reads "date", but does not declare it. Add {{#expect date}} at the top of the partial.');
899
+
awaitexpect(build({cwd: root})).rejects.toThrow('partials/blog/meta.hbs reads "date", but does not declare it; add {{#expect date}} at the top of the partial, rendering content/index.html');
900
+
}finally{
901
+
awaitrm(root,{recursive: true,force: true});
902
+
}
903
+
});
904
+
905
+
test('a name that a function the partial calls cannot find is not a name of the partial',async()=>{
thrownewError(`partials/${file.replace(/\\/g,'/')} reads "${name}", but does not declare it. Add {{#expect ${name}}} at the top of the partial.`,{cause: err});
229
+
letname=found&&(found[1]||found[2]);
230
+
// a function that the partial calls can miss a name too, which the partial never names
thrownewError(`partials/${file.replace(/\\/g,'/')} reads "${name}", but does not declare it; add {{#expect ${name}}} at the top of the partial`,{cause: err});
0 commit comments