-
Notifications
You must be signed in to change notification settings - Fork 2
/
06-listings.qmd
418 lines (321 loc) · 8.4 KB
/
06-listings.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
---
format:
revealjs:
theme: [default, slide-styles.scss]
width: 1280
height: 720
include-after-body:
- "all-the-js-code.html"
echo: false
code-line-numbers: false
---
# Listings
## Let's add a blog
`blog/` has some folders with documents in them
**Demo:**
1. Make a new page `blog/index.qmd`
2. Make it a listing:
::::: columns
::: column
As simple as:
``` yaml
---
title: My Blog
listing: default
---
```
:::
::: column
Explicit default options:
``` yaml
---
title: My Blog
listing:
contents: /
sort: "date"
type: default
categories: false
---
```
:::
:::::
## A listing is...
::::: columns
::: column
- an automatically generated list of content
- styled via a template, (built-in `type`, or custom `template`)
- can be included on any page
:::
::: column
![](images/listings-default.png)
:::
:::::
## Generated from documents in `contents`
::::: columns
::: column
![](images/listings-first.png)
:::
::: column
``` {.yaml filename="blog/third-post/index.qmd"}
---
title: "First Post"
description: "Post description for first post"
author: "Alicia"
date: "5/22/2021"
image: "cover.jpg"
categories:
- Science
- Technology
---
```
:::
:::::
## Why use a listing?
- Great for large collections
- Great for collections that grow
## Your Turn
1. (Repeat) Make a new page `blog/index.qmd` which is a listing
2. Experiment with `type` and `categories`:
* `type`: `grid` or `table`
* `categories`: `true`, `unnumbered`, `cloud`
[Other listing options](https://quarto.org/docs/websites/website-listings.html#listing-options)
3. Discuss with your neighbor:
- What makes this a blog?
- What would you change if this was a gallery of your projects?
{{< countdown 10:00 >}}
## Default
![](images/listings-default.png)
## Grid
![](images/listings-grid.png)
## Table
![](images/listings-table.png)
## Categories
::: {.columns}
::: {.column}
![`true`/`numbered`](images/listings-categories-true.png)
![`unnumbered`](images/listings-categories-unnumbered.png)
:::
::: {.column}
![`cloud`](images/listings-categories-cloud.png)
:::
:::
## Use listings for \_ projects \_
<https://ivelasq.rbind.io/project>
![](images/listings-projects-example.png)
::: footer
More examples at: <https://charlotte.quarto.pub/listings/>
:::
## Use listings for \_ talks \_
<https://meghan.rbind.io/talks/>
![](images/listings-talks.png)
::: footer
More examples at: <https://charlotte.quarto.pub/listings/>
:::
## Use listings for \_ publications \_
<https://mickael.canouil.fr/publications>
![](images/listings-publications.png)
::: footer
More examples at: <https://charlotte.quarto.pub/listings/>
:::
## Use listings for ...
<https://charlotte.quarto.pub/listings/>
```{=html}
<iframe src="https://charlotte.quarto.pub/listings/" width="100%" height="550" title="Listing Examples"></iframe>
```
## `contents` can be a YAML file
::: {.columns}
::: {.column}
```{.yaml filename="projects/index.qmd"}
---
title: Projects
listing:
contents: projects.yml
type: grid
max-description-length: 250
---
```
:::
::: {.column}
```{.yaml filename="project/projects.yml"}
- title: Predicting House Prices with Machine Learning
path: https://example.com/house-prices
# Photo by Breno Assis on Unsplash https://unsplash.com/photos/aerial-photography-of-rural-r3WAWU5Fi5Q
image: images/breno-assis-r3WAWU5Fi5Q-unsplash.jpg
description: >
This project involves using machine learning algorithms to predict house prices based on
various features such as location, size, and amenities. It includes data cleaning,
feature engineering, and model selection.
categories: [Python, Machine Learning, Data Cleaning]
date: 2024-01-01
...
```
`path` can be a relative path to a file in your site, or a URL
You can use [Listing Fields](https://quarto.org/docs/websites/website-listings.html#listing-fields), or create custom ones.
:::
:::
## `contents` can be a YAML file
![](images/listings-projects.png)
## Simple Customization: Select Fields
::: {.columns}
::: {.column width="40%"}
Use `fields` to specify which [Listing Fields](https://quarto.org/docs/websites/website-listings.html#listing-fields) are displayed.
:::
::: {.column width="60%"}
E.g. Exclude `date`:
```{.yaml}
listing:
contents: projects.yml
type: grid
fields: ["image", "title", "categories", "description"]
```
:::
:::
## Simple Customization: Rename Fields
::: {.columns}
::: {.column width="40%"}
Use `field-display-names` to provide a different label for a field
Mostly useful for `type: table`.
:::
::: {.column width="60%"}
E.g. Rename `title` to `Project`
```{.yaml}
listing:
contents: projects.yml
type: table
field-display-names:
title: Project
```
:::
:::
## Your Turn
1. Switch to `type: table`
2. Omit the `image` field from the listing
3. Change the name of the "Categories" column to "Skills"
4. Brainstorm: What could you use a listing for on your own site?
{{< countdown 10:00 >}}
## Advanced Customization
Example: <https://www.andrewheiss.com/teaching/>
Source: <https://github.com/andrewheiss/ath-quarto/blob/main/teaching/index.qmd>
- Listing in a custom location on a page
- More than one listing on a page
- Custom Template
## Custom Location
::: {.columns}
::: {.column}
```{.yaml filename="teaching/index.qmd"}
---
title: "Teaching"
listing:
id: ay_23-24
contents: ay_23-24.yml
---
```
Give the listing an `id`
:::
::: {.column}
```{.markdown filename="teaching/index.qmd"}
## 2023–24
:::{#ay_23-24}
:::
## 2022–23
```
Use the `id` in a fenced div where you want it to appear
:::
:::
## Multiple Listings
::: {.columns}
::: {.column}
```{.yaml filename="teaching/index.qmd"}
---
title: "Teaching"
listing:
- id: ay_23-24
contents: ay_23-24.yml
- id: ay_22-23
contents: ay_22-23.yml
---
```
Make `listing` an array, use `id`s
:::
::: {.column}
```{.markdown filename="teaching/index.qmd"}
## 2023–24
:::{#ay_23-24}
:::
## 2022–23
:::{#ay_22-23}
:::
```
Place listings in the page by `id`
:::
:::
## Custom template
::: {.columns}
::: {.column}
```{.yaml filename="teaching/index.qmd"}
---
title: "Teaching"
listing:
- id: ay_23-24
contents: ay_23-24.yml
template: ../html/teaching/listing.ejs
---
```
Provide an `ejs` file to `template`
:::
::: {.column}
````{.html filename="../html/teaching/listing.ejs"}
```{=html}
<div class="teaching">
<% for (const course of items) { %>
<div class="course-entry">
<div class="logo">
<% if (course.url) { %>
<a href="<%= course.url %>" target="_blank"><img src="<%= course.logo %>" alt="<%= course.title %>" title="<%= course.title %>" /></a>
<% } else { %>
<img src="<%= course.logo %>" alt="<%= course.title %>" title="<%= course.title %>" />
<% } %>
</div>
<div class="body">
<p class="course-title">
<% if (course.url) { %>
<a href="<%= course.url %>" target="_blank"><%= course.title %></a>
<% } else { %>
<%= course.title %>
<% } %>
</p>
<p class="course-details">
<span class="course-number"><%= course.number %></span> |
<span class="course-university"><%= course.university %></span>
<% if (course.role) { %>
| <span class="course-role"><%= course.role %></span>
<% } %>
</p>
<p class="course-description"><%= course.description %></p>
<ul class="course-semesters">
<% for (const semester of course.semester) { %>
<% if (semester.url) { %>
<li><a href="<%= semester.url %>"><i class="fa-solid fa-building-columns"></i> <%= semester.name %></a></li>
<% } else { %>
<li class="no-link"><i class="fa-solid fa-building-columns"></i> <%= semester.name %></li>
<% } %>
<% } %>
</ul>
</div>
</div>
<% } %>
</div>
```
````
Define how item in `items` should be generated
:::
:::
## Your Turn
**Add a listing page to your site**:
1. Create a page to house the listing
2. Either:
- populate a `.yml` file with a couple of items (use `projects/project.yml` as a template), or
- create some placeholder `.qmd` files.
3. Add the page to your site navigation
4. Clean up any template listing pages/files/folders you don't want
{{< countdown 10:00 >}}