https://github.com/kulla/2025-05-13-rendering-serlo-content-per-cli
https://github.com/kulla/2025-05-13-rendering-serlo-content-per-cli
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kulla/2025-05-13-rendering-serlo-content-per-cli
- Owner: kulla
- Created: 2025-05-13T09:18:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-05T12:15:19.000Z (11 months ago)
- Last Synced: 2025-07-05T13:27:46.806Z (11 months ago)
- Language: TypeScript
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 2025-05-13-rendering-serlo-content-per-cli
## Setup & Execution
1. Clone repository
2. Run `npm install`
3. Run `npm run build` to build `src/render.tsx` to `dist/render.js`
4. Run `npm run execute:script` to execute `dist/render.js` with Node.js
One can also run `npm run execute` to combine the `build` and `execute:script` commands. This will build the script and execute it in one command.
After executing the script the rendered HTML can be found at `output.html` in the root directory of the repository.
## CLI use via node
To run the script using *node* only, run `node dist/render.js ` to save it to a file `output.html` or `node dist/render.js --stdout ` to print the output to the console.
## ToDos
- [x] `output.html` is actually not a valid HTML file. It only contains the body of the HTML file.
- [x] The CSS for the serlo editor needs to be added as well (see `node_modules/@serlo/editor/dist/style.css`).
- [] `hydrateRoot()` needs to be called in the browser to make the editor interactive (see https://18.react.dev/reference/react-dom/server/renderToPipeableStream#rendering-a-react-tree-as-html-to-a-nodejs-stream)