Skip to content

Commit b745836

Browse files
committed
feat(blog): wrote listing of pages section
1 parent cb36333 commit b745836

7 files changed

Lines changed: 112 additions & 0 deletions

File tree

284 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Example 1
3+
---
4+
5+
This page has a picture of a butterfly.
6+
7+
![Butterfly](butterfly.jpg)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Example 2
3+
---
4+
5+
This page has a picture of a squirrel.
6+
7+
![Squirrel](squirrel.jpg)
422 KB
Loading
346 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Example 3
3+
---
4+
5+
This page has a picture of a cat.
6+
7+
![Cat](cat.jpg)

pages/blog/index.qmd

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
title: Listings (e.g., blog)
33
listing:
4+
- id: simple
5+
contents: examples
6+
type: grid
7+
grid-columns: 3
48
- id: links
59
contents: links_real.yml
610
template: links.ejs
@@ -15,6 +19,93 @@ There are two ways to use listings:
1519

1620
## Listing of pages
1721

22+
### Simple listing of pages
23+
24+
A common use case is a blog or "Projects" page that lists documents from a folder. We create it with `listing:` in the YAML. At a minimum, you specify `contents`, which determines which documents to include.
25+
26+
For example, this will create a listing from files within the `pages/` folder:
27+
28+
```{.markdown}
29+
---
30+
title: Projects
31+
listing:
32+
contents: pages
33+
---
34+
```
35+
36+
In this example, we have add more criteria:
37+
38+
* `type:` how to display the items (for example, `default` list or `grid`).
39+
* `grid-columns:` number of columns when using a grid layout.
40+
* `fields:` which pieces of metadata to show for each item (for example, `title`, `subtitle`, `image`).
41+
* `image-height:` how tall to show any image field.
42+
43+
```{.markdown}
44+
---
45+
title: Projects
46+
listing:
47+
contents: pages
48+
type: grid
49+
grid-columns: 3
50+
fields: [title, subtitle, image]
51+
image-height: "100"
52+
---
53+
```
54+
55+
Example:
56+
57+
::: {#simple}
58+
:::
59+
60+
### Grouped listing of pages
61+
62+
You can also define **multiple listings** on the same page and group them.
63+
64+
This approach assumes that the pages in `pages/` have a `year:` field in their YAML. Each listing block uses `include:` to filter by `year`, and an `id` that matches a placeholder div later in the document.
65+
66+
```{.markdown}
67+
---
68+
title: Projects
69+
listing:
70+
- id: projects-2026
71+
contents: pages
72+
include:
73+
year: 2026
74+
fields: [title, subtitle, image]
75+
76+
- id: projects-2025
77+
contents: pages
78+
include:
79+
year: 2025
80+
fields: [title, subtitle, image]
81+
82+
- id: projects-2024
83+
contents: pages
84+
include:
85+
year: 2024
86+
fields: [title, subtitle, image]
87+
88+
format:
89+
html:
90+
page-layout: article
91+
---
92+
93+
## 2026
94+
95+
::: {#projects-2026}
96+
:::
97+
98+
## 2025
99+
100+
::: {#projects-2025}
101+
:::
102+
103+
## 2024
104+
105+
::: {#projects-2024}
106+
:::
107+
```
108+
18109
## Listing of external things
19110

20111
**Note:** This is more advanced. The approach is based on `quarto-dev/quarto-web`'s gallery ([link](https://github.com/quarto-dev/quarto-web/blob/main/docs/gallery/gallery.ejs)).

0 commit comments

Comments
 (0)