Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions websites/quarto-meta-includes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.quarto/
_site/
10 changes: 10 additions & 0 deletions websites/quarto-meta-includes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
See live at <https://examples.quarto.pub/quarto-meta-includes/>

## About this example

This example accompanies the blog post at <https://quarto.org/docs/blog/posts/2024-12-20-includes-meta>

It illustrates combining the `meta` and `include` shortcodes.

Original source: <https://github.com/AshleyHenry15/blog-quarto-meta-vars>

4 changes: 4 additions & 0 deletions websites/quarto-meta-includes/_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- source: project
quarto-pub:
- id: 5dac494e-2416-4aec-b16e-740cd3391972
url: https://examples.quarto.pub/quarto-meta-includes
25 changes: 25 additions & 0 deletions websites/quarto-meta-includes/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
project:
type: website

website:
title: "`meta` Shortcodes for Precise Includes"
repo-url: https://github.com/quarto-dev/quarto-examples
repo-subdir: websites/quarto-meta-includes
repo-actions: [source]
navbar:
left:
- href: index.qmd
text: "Home"
- href: new-york.qmd
- href: pa.qmd



format:
html:
theme: yeti
css: styles.css
toc: true



11 changes: 11 additions & 0 deletions websites/quarto-meta-includes/_snippets/facts.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{< 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 >}}.

{{< meta state >}}'s official flower is the {{< meta flower >}}, pictured below:

![The official {{< meta state >}} state flower, the {{< meta flower >}}](/images/{{< meta state-abbr >}}/flower.png)

Lastly, {{< meta state >}}'s official animal is the {{< meta animal >}}, pictured below:

![The official {{< meta state >}} state animal, the {{< meta animal >}}](/images/{{< meta state-abbr >}}/animal.png)


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions websites/quarto-meta-includes/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "`meta` Shortcodes for Precise Includes"
author: Ashley Henry
---

This is an example site to showcase the use of `meta` shortcodes for more precise includes using Quarto.

It accompanies the blog post at: <https://quarto.org/docs/blog/posts/2024-12-20-includes-meta>

The pages for [New York](new-york.qmd) and [Pennsylvania](pa.qmd) are generated by including the same snippet:

````{.markdown filename="_snippets/facts.qmd" shortcodes="false"}
{{< 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 >}}.

{{< meta state >}}'s official flower is the {{< meta flower >}}, pictured below:

![The official {{< meta state >}} state flower, the {{< meta flower >}}](/images/{{< meta state-abbr >}}/flower.png)

Lastly, {{< meta state >}}'s official animal is the {{< meta animal >}}, pictured below:

![The official {{< meta state >}} state animal, the {{< meta animal >}}](/images/{{< meta state-abbr >}}/animal.png)
````

Where the relevant variables are set in each page's metadata, e.g.:

```{.yaml filename="new-york.qmd"}
---
title: New York
state-abbr: ny
state: New York
size-rank: 27th
square-miles: 54,555
population: 19.8 million
flower: Rose
animal: Beaver
---
```
12 changes: 12 additions & 0 deletions websites/quarto-meta-includes/new-york.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: New York
state-abbr: ny
state: New York
size-rank: 27th
square-miles: 54,555
population: 19.8 million
flower: Rose
animal: Beaver
---

{{< include _snippets/facts.qmd >}}
12 changes: 12 additions & 0 deletions websites/quarto-meta-includes/pa.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Pennsylvania
state-abbr: pa
state: Pennsylvania
size-rank: 33rd
square-miles: 46,055
population: 12.9 million
flower: Mountain Laurel
animal: White-tailed Deer
---

{{< include _snippets/facts.qmd >}}
5 changes: 5 additions & 0 deletions websites/quarto-meta-includes/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* css styles */

code {
background-color: inherit;
}