Skip to content

Commit 5a996c1

Browse files
committed
Stop documentation include directive from being processed
1 parent 8767567 commit 5a996c1

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

example.qmd

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,38 @@ author: James Goldie, 360info
44
date: last-modified
55
---
66

7-
:::{.svelteimport}
7+
:::{}
88
{{< include /.sverto/example.qmd >}}
99
:::
1010

1111
Here's an example of how to use the included example Svelte component, `Circles.svelte`. There are six steps:
1212

13-
### 2. Add a magic block to the top of your document
13+
### 1. Add a magic block to the top of your document
1414

1515
Add a magic block anywhere in your document that looks like this:
1616

1717
````markdown
18-
:::
19-
{{< include /.sverto/example.qmd >}}
18+
:::{}
19+
{{{< include /.sverto/example.qmd >}}}
2020
:::
2121
````
2222

2323
Replace `example.qmd` with the path to your Quarto doc within the project. For example:
2424

2525
**If your document is here...** | **Use this import path**
2626
--------------------------------|------------------------------------------
27-
`example.qmd` | `.sverto/example.qmd`
28-
`posts/animals/turtles.qmd` | `.sverto/posts/animals/turtles.qmd`
27+
`example.qmd` | `/.sverto/example.qmd`
28+
`posts/animals/turtles.qmd` | `/.sverto/posts/animals/turtles.qmd`
2929

30-
> If you ever move or rename your Quarto document, you'll need to update this block with the new location and filename!
30+
:::{.callout-warning}
31+
This magic block must be the **first** thing in your document---straight after the frontmatter!
32+
33+
If you ever move or rename your Quarto document, you'll need to update this block with the new location and filename.
34+
:::
3135

3236
### 2. Import the component
3337

34-
Import your Svelte file in an OJS block. Here we call the result `Circles`:
38+
Import your Svelte file in an OJS block using the `import_svelte` function. Here we call the result `Circles`:
3539

3640
```{ojs}
3741
Circles = import_svelte("Circles.svelte")
@@ -43,16 +47,21 @@ We need to create an instance of our imported component, but---unlike a typical
4347

4448
Create an empty div in your document and give it an #id with the hashtag. This will be the "target" in the next step, when we bring the component to life, or _instantiate_ it:
4549

46-
````markdown
50+
```markdown
4751
:::{#mycircles}
4852
:::
49-
````
53+
```
5054

5155
:::{#mycircles}
5256
:::
5357

54-
> **Tip:** this block can go anywhere in your document! In fact, order doesn't matter for any of these steps, other than the frontmatter.
58+
:::{.callout-tip}
59+
This block can go anywhere in your document! Feel free to put it well after the following steps, where you actually want your visualisation to appear.
60+
:::
5561

62+
:::{.callout-tip}
63+
If you know how how to use CSS, you can target `#mycircles` to position or size your visualisation as you'd like.
64+
:::
5665

5766
### 4. Instantiate your component
5867

@@ -72,11 +81,13 @@ myCircles = new Circles.default({
7281
});
7382
```
7483

75-
> **Important:** if you're creating a visual that will react in response to changing OJS (for example, some data that you've calculated in your document, or the value of an Observable Input), _do not put that data here._
76-
>
77-
> If you put changing data here, the Svelte component will rebuild from scratch every time the data changes, and it will not animate.
78-
>
79-
> Instead, we're going to take advantage of Svelte's own reactivity in the next step.
84+
::: {.callout-important}
85+
If you're creating a visual that will react in response to changing OJS (for example, some data that you've calculated in your document, or the value of an Observable Input), **do not put that data here.**
86+
87+
If you put changing data here, the Svelte component will rebuild from scratch every time the data changes, and it will not animate.
88+
89+
Instead, we're going to take advantage of Svelte's own reactivity in the next step.
90+
:::
8091

8192
### 5. Update your component
8293

@@ -106,15 +117,19 @@ myCircles.data = selectedDataset
106117

107118
You can't see anything here, but if we scroll back up to where we added the empty `#mycircles` block, you can see it transition whenever we select a new dataset!
108119

109-
> **Tip:** you can put `#mycircles` wherever you want in the document - it doesn't have to be in order!
120+
:::{.callout-tip}
121+
You can put `#mycircles` wherever you want in the document - it doesn't have to be in order!
122+
:::
110123

111124
### 6. Render the project
112125

113126
Render your Quarto project as you normally would, with commands like `quarto run` and `quarto preview`.
114127

115-
> **Note:** you'll probably get the warning "OJS block count mismatch. Line number reporting is likely to be wrong" when rendering.
116-
>
117-
> That's because of what we're doing under the hood to bring the Svelte files in. It won't stop your project from working, but be aware of it if you are referring to line numbers in code blocks!
128+
:::{.callout-note}
129+
You'll probably get the warning `OJS block count mismatch. Line number reporting is likely to be wrong` when rendering.
130+
131+
That's because of what we're doing under the hood to bring the Svelte files in. It won't stop your project from working, but be aware of it if you are referring to line numbers in code blocks!
132+
:::
118133

119134
And there you go! 🚀
120135

0 commit comments

Comments
 (0)