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
Copy file name to clipboardExpand all lines: README.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,17 +26,17 @@ This will install everything you need for your Svelte components to work to the
26
26
27
27
## 🎉 Use
28
28
29
-
Here's the short version of adding Svelte components to your Quarto docs:
29
+
Here's the short way to add Svelte component you've written to a Quarto doc:
30
30
31
-
1. Add a list of Svelte components (eg. `Circles.svelte`) you want to add to your document frontmatter under `svelte`
32
-
2. Add a magic placeholder div to your document using the `.svelteimport` class and a [Quarto include](https://quarto.org/docs/authoring/includes.html) to the path to your Quarto doc, prefixed with `/.sverto/`. For example:
31
+
1. Add a magic placeholder block to your document with a [Quarto include](https://quarto.org/docs/authoring/includes.html) to the path to your Quarto doc, prefixed with `/.sverto/`. For example:
33
32
34
-
````
35
-
:::{.svelteimport}
33
+
```
34
+
:::{}
36
35
{{< include /.sverto/example.qmd >}}
37
36
:::
38
-
````
37
+
```
39
38
39
+
2. Import your Svelte component with `Component = import_svelte("Component.svelte")`
40
40
3. Add a target block for your visual and give it an `#id`
41
41
4. Instantiate the Svelte component with `myVisual = Component.default()` using some default props and your target block
42
42
5. Update the instantiated component with `myVisual.propName`
@@ -49,7 +49,7 @@ Here's the short version of adding Svelte components to your Quarto docs:
49
49
* [`example.qmd`](./example.qmd): an example Quarto doc that uses a Svelte component
50
50
* [`Circles.svelte`](./Circles.svelte): an example Svelte visualisation
51
51
* [`package.json`](./package.json): this is used to keep track of the dependencies of your Svelte components. You should add this to version control.
52
-
* Once you've run `npm install`, there'll also be a `package-lock.json`. You should version control this too.
52
+
* Once you've run `npm install`, there'll also be a `package-lock.json` and a `.luarc.json`. You should version control these too (although you oughtn't need to edit them manually).
53
53
54
54
See [`example.qmd`](./example.qmd) to learn how to add Svelte components to your documents and the [Svelte tutorial](https://svelte.dev/tutorial/basics) to learn how to create them.
55
55
@@ -61,9 +61,11 @@ If you want to refer to other JavaScript libraries in your Svelte component (lik
61
61
npm install d3-scale
62
62
```
63
63
64
-
If you'd prefer to compile your own Svelte components instead of letting this extension do it, you can skip steps 1 and 2 and simply refer to the compiled bundle with, for example, `Circles = require("Circles.js")` in an OJS block.
64
+
## Use pre-compiled Svelte components
65
65
66
-
You must compiled Svelte component to ES6 bundles, and you must enable accessors when compiling if you want to be able to update them from OJS.
66
+
If you'd prefer to compile your own Svelte components instead of letting this extension do it, you can skip steps 1 and 2 and simply refer to the compiled bundle with, for example, `Component = import("Component.js")` in an OJS block.
67
+
68
+
> **Note:** you must compile the Svelte component to an ES6 bundle, and you must enable accessors when compiling if you want to be able to update them from OJS. Refer to `_extensions/sverto/rollup.config.js` for guidance on configuring Rollup to do this.
0 commit comments