Skip to content

Commit

Permalink
docs: update main example
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Oct 29, 2023
1 parent 50132e2 commit 554e8d7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,21 @@ Import `typst.ts` in your project:
- Using [@myriaddreamin/typst.ts][npm::typst.ts]

```typescript
import { createTypstRenderer } from '@myriaddreamin/typst.ts';
const renderer = createTypstRenderer();
await renderer.init();
const svg = await renderer.runWithSession(async session => {
// do something with session
});
import { $typst } from '@myriaddreamin/typst.ts/dist/esm/contrib/snippet.mjs';
const mainContent = 'Hello, typst!';

console.log(await $typst.svg({ mainContent }));
```

Specify correct path to the wasm modules if it complains.

```typescript
$typst.setCompilerInitOptions({ getModule: ... });
$typst.setRendererInitOptions({ getModule: ... });
```

The path option is likely required in browser but not in node.js.

- Using [@myriaddreamin/typst.react][npm::typst.react]

```typescript
Expand Down

0 comments on commit 554e8d7

Please sign in to comment.