Skip to content

Commit 49cd294

Browse files
authored
Merge pull request #4 from quarto-dev/meta-include
Add example of meta include from blogpost
2 parents ced501e + 2696355 commit 49cd294

File tree

13 files changed

+118
-0
lines changed

13 files changed

+118
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
_site/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
See live at <https://examples.quarto.pub/quarto-meta-includes/>
2+
3+
## About this example
4+
5+
This example accompanies the blog post at <https://quarto.org/docs/blog/posts/2024-12-20-includes-meta>
6+
7+
It illustrates combining the `meta` and `include` shortcodes.
8+
9+
Original source: <https://github.com/AshleyHenry15/blog-quarto-meta-vars>
10+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- source: project
2+
quarto-pub:
3+
- id: 5dac494e-2416-4aec-b16e-740cd3391972
4+
url: https://examples.quarto.pub/quarto-meta-includes
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "`meta` Shortcodes for Precise Includes"
6+
repo-url: https://github.com/quarto-dev/quarto-examples
7+
repo-subdir: websites/quarto-meta-includes
8+
repo-actions: [source]
9+
navbar:
10+
left:
11+
- href: index.qmd
12+
text: "Home"
13+
- href: new-york.qmd
14+
- href: pa.qmd
15+
16+
17+
18+
format:
19+
html:
20+
theme: yeti
21+
css: styles.css
22+
toc: true
23+
24+
25+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{< meta state >}} covers approximately {{< meta square-miles >}} making it the {{< meta size-rank >}} largest state in the United States. As of 2023, {{< meta state >}} has an approximate population of about {{< meta population >}}.
2+
3+
{{< meta state >}}'s official flower is the {{< meta flower >}}, pictured below:
4+
5+
![The official {{< meta state >}} state flower, the {{< meta flower >}}](/images/{{< meta state-abbr >}}/flower.png)
6+
7+
Lastly, {{< meta state >}}'s official animal is the {{< meta animal >}}, pictured below:
8+
9+
![The official {{< meta state >}} state animal, the {{< meta animal >}}](/images/{{< meta state-abbr >}}/animal.png)
10+
11+
72.5 KB
Loading
41.3 KB
Loading
60.9 KB
Loading
121 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "`meta` Shortcodes for Precise Includes"
3+
author: Ashley Henry
4+
---
5+
6+
This is an example site to showcase the use of `meta` shortcodes for more precise includes using Quarto.
7+
8+
It accompanies the blog post at: <https://quarto.org/docs/blog/posts/2024-12-20-includes-meta>
9+
10+
The pages for [New York](new-york.qmd) and [Pennsylvania](pa.qmd) are generated by including the same snippet:
11+
12+
````{.markdown filename="_snippets/facts.qmd" shortcodes="false"}
13+
{{< meta state >}} covers approximately {{< meta square-miles >}} making it the {{< meta size-rank >}} largest state in the United States. As of 2023, {{< meta state >}} has an approximate population of about {{< meta population >}}.
14+
15+
{{< meta state >}}'s official flower is the {{< meta flower >}}, pictured below:
16+
17+
![The official {{< meta state >}} state flower, the {{< meta flower >}}](/images/{{< meta state-abbr >}}/flower.png)
18+
19+
Lastly, {{< meta state >}}'s official animal is the {{< meta animal >}}, pictured below:
20+
21+
![The official {{< meta state >}} state animal, the {{< meta animal >}}](/images/{{< meta state-abbr >}}/animal.png)
22+
````
23+
24+
Where the relevant variables are set in each page's metadata, e.g.:
25+
26+
```{.yaml filename="new-york.qmd"}
27+
---
28+
title: New York
29+
state-abbr: ny
30+
state: New York
31+
size-rank: 27th
32+
square-miles: 54,555
33+
population: 19.8 million
34+
flower: Rose
35+
animal: Beaver
36+
---
37+
```

0 commit comments

Comments
 (0)