Skip to content

Instantly share code, notes, and snippets.

@jimjam-slam
Created February 15, 2023 04:36
Show Gist options
  • Save jimjam-slam/e9325abcb7c07b64e1f6d7b6a6f88d03 to your computer and use it in GitHub Desktop.
Save jimjam-slam/e9325abcb7c07b64e1f6d7b6a6f88d03 to your computer and use it in GitHub Desktop.
Accessing custom, nested Quarto document metadata in other listings
project:
type: website
---
title: "Doc metadata test - index"
author: "James"
listing:
template: postlist.ejs
id: mylisting
contents: post*.qmd
---
Here's a listing of _all_ my posts, with links and the list of people in each:
:::{#mylisting style="background-color: #eeeeee"}
:::
Listing over!
```{=html}
<% for (const person of items) { %>
<h2><%= person.name %></h2>
<ul>
<% for (const link of person.links) { %>
<li><%= link %></li>
<% } %>
</ul>
<% } %>
```
---
title: "Doc metadata test - post 1"
listing:
template: post.ejs
id: mylisting
contents:
- name: James
links:
- linkedin
- twitter
---
My listing is going to go here:
:::{#mylisting style="background-color: #999999"}
:::
Listing over!
---
title: "Doc metadata test - post 2"
listing:
template: post.ejs
id: mylisting
contents:
- name: Sam
links:
- pixabay
- facebook
---
My listing is going to go here:
:::{#mylisting style="background-color: #eeeeee"}
:::
Listing over!
```{=html}
<h1>All people</h1>
<% for (const doc of items) { %>
<a href="<%= doc.path %>"><h2><%= doc.title %></h2></a>
<h3>People in this post:</h3>
<% for (const person of doc.listing.contents) { %>
<h4><%= person.name %></h4>
<ul>
<% for (const link of person.links) { %>
<li><%= link %></li>
<% } %>
</ul>
<% } %>
<% } %>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment