feat(web): allow JS in template, absolute URL support#751
feat(web): allow JS in template, absolute URL support#751avivkeller wants to merge 7 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Adds Fixes Orama DB document Reviewed by Cursor Bugbot for commit f4c6dd9. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #751 +/- ##
==========================================
+ Coverage 77.08% 78.36% +1.27%
==========================================
Files 153 156 +3
Lines 13749 13918 +169
Branches 1111 1146 +35
==========================================
+ Hits 10599 10907 +308
+ Misses 3146 3006 -140
- Partials 4 5 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
| File | Base | Head | Diff |
|---|---|---|---|
orama-db.json |
8.27 MB | 8.28 MB | +9.95 KB (+0.12%) |
There was a problem hiding this comment.
Pull request overview
Adds support to the web generator for (1) generating absolute-style URLs based on configuration and (2) evaluating template.html as a JavaScript template literal to allow more advanced template expressions.
Changes:
- Introduces
relativeOrAbsolute()utilities (server + UI) and updates UI components/hooks to use them. - Switches HTML template population to a
new Function-based template-literal evaluation and updates the defaulttemplate.htmlplaceholders. - Adds tests for
relativeOrAbsoluteandpopulateWithEvaluation, and bumps package version.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/generators/web/utils/relativeOrAbsolute.mjs | New server-side helper to emit relative vs absolute URLs based on web config |
| src/generators/web/utils/processing.mjs | Switches HTML rendering to template-literal evaluation; uses relativeOrAbsolute for root URL |
| src/generators/web/utils/tests/relativeOrAbsolute.test.mjs | Adds unit tests for relative/absolute URL behavior |
| src/generators/web/utils/tests/processing.test.mjs | Adds unit tests for populateWithEvaluation |
| src/generators/web/ui/utils/relativeOrAbsolute.mjs | New UI-side helper using #theme/config for URL mode selection |
| src/generators/web/ui/hooks/useOrama.mjs | Uses relativeOrAbsolute when fetching Orama DB |
| src/generators/web/ui/components/SideBar/index.jsx | Uses relativeOrAbsolute for navigation link generation |
| src/generators/web/ui/components/SearchBox/index.jsx | Uses relativeOrAbsolute for search result links |
| src/generators/web/types.d.ts | Adds useAbsoluteURLs to web generator configuration typing |
| src/generators/web/template.html | Updates placeholders to ${...} to match template-literal evaluation |
| src/generators/web/index.mjs | Adds default useAbsoluteURLs: false |
| package.json | Version bump to 1.3.3 |
| package-lock.json | Lockfile version bump to 1.3.3 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I don't like this AT all. Why? Can you properly explain why this is needed? What are we solving that needs this? |
I'd like to pass more data to the template file, like we do here (for example). There are plenty of cases where this is needed, such as when:
As for eval-ed inline code, that shouldn't happen, as long as the user doesn't wrap it in |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit acf914c. Configure here.

Ref: nodejs/learn#29
Adds:
template.html(NOTE: This file is run in the main context. It should be assumed that users TRUST thetemplate.htmlfile they are providing)relativeOrAbsoluteallows users to specify whether they wantdoc-kitto generate absolute-style or relative-style URLsThere should be a minimal size-difference to the output bundle