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: example.qmd
+14-22Lines changed: 14 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -2,39 +2,23 @@
2
2
title: Svelte example
3
3
author: James Goldie, 360info
4
4
date: last-modified
5
-
svelte:
6
-
- Circles.svelte
7
5
---
8
6
9
-
Here's an example of how to use the included example Svelte component, `Circles.svelte`. There are six steps:
10
-
11
-
### 1. Import the component
12
-
13
-
The first thing you should note is in the frontmatter: a `svelte` key with a list of Svelte components. For example:
7
+
:::{.svelteimport}
8
+
{{< include /.sverto/example.qmd >}}
9
+
:::
14
10
15
-
```yaml
16
-
---
17
-
title: Svelte example
18
-
svelte:
19
-
- Circles.svelte
20
-
---
21
-
```
11
+
Here's an example of how to use the included example Svelte component, `Circles.svelte`. There are six steps:
22
12
23
-
### 2. Add a magic block to your document
13
+
### 2. Add a magic block to the top of your document
24
14
25
15
Add a magic block anywhere in your document that looks like this:
26
16
27
17
````markdown
28
-
:::{.svelteimport}
29
-
{{< import /.sverto/example.qmd >}}
30
18
:::
31
-
````
32
-
33
-
When this document renders, it'll turn into an OJS block with a series of statements like `X = import("X.js")`:
34
-
35
-
:::{.svelteimport}
36
19
{{< include /.sverto/example.qmd >}}
37
20
:::
21
+
````
38
22
39
23
Replace `example.qmd` with the path to your Quarto doc within the project. For example:
40
24
@@ -45,6 +29,14 @@ Replace `example.qmd` with the path to your Quarto doc within the project. For e
45
29
46
30
> If you ever move or rename your Quarto document, you'll need to update this block with the new location and filename!
47
31
32
+
### 2. Import the component
33
+
34
+
Import your Svelte file in an OJS block. Here we call the result `Circles`:
35
+
36
+
```{ojs}
37
+
Circles = import_svelte("Circles.svelte")
38
+
```
39
+
48
40
### 3. Create a place for your visual to live
49
41
50
42
We need to create an instance of our imported component, but---unlike a typical OJS block---Svelte components put the visual itself somewhere else in the document.
0 commit comments