Skip to content

Commit 001d90c

Browse files
authored
Merge pull request #298 from jaladh-singhal/auto-gen-gallery
Add `notebook-gallery` plugin to auto-generate gallery style cards on index pages
2 parents bc2b0b8 + b6ba1e2 commit 001d90c

12 files changed

Lines changed: 767 additions & 99 deletions

File tree

myst.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ project:
2525
- https://irsa.ipac.caltech.edu/cgi-bin/Gator/nph-scan?projshort=SPITZER
2626
# GH is rather flaky for CI right now, temporarily measure
2727
- 'https://github.com/**'
28-
28+
plugins:
29+
# note: we need to use the built plugin bundle here so make sure to build it with
30+
# `cd plugins && npm install && npm run build` after any changes to the plugins/src/
31+
- plugins/dist/notebook-gallery.mjs
32+
2933
extends:
3034
- toc.yml
3135
site:

plugins/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

plugins/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# IRSA MyST Plugins
2+
3+
Custom [MyST](https://mystmd.org) plugins for the irsa-tutorials.
4+
5+
## Building
6+
7+
```bash
8+
cd plugins
9+
npm install
10+
npm run build
11+
```
12+
13+
This bundles `src/notebook-gallery.mjs` into `dist/notebook-gallery.mjs`. Must *re-run* after any changes to `src/`.
14+
15+
## Registering with MyST
16+
17+
Add the built bundle to `myst.yml`:
18+
19+
```yaml
20+
project:
21+
plugins:
22+
- plugins/dist/notebook-gallery.mjs
23+
```
24+
25+
---
26+
27+
## Plugin: `notebook-gallery` directive
28+
29+
Renders a list of notebooks as a responsive grid of clickable cards. Each card shows a title and a one-sentence description pulled from a shared metadata file.
30+
31+
### Metadata file
32+
33+
The directive argument is a path to a YAML or JSON file (relative to the repo root) that lists notebook metadata. Each entry must have at least:
34+
35+
| Field | Type | Description |
36+
| ------------- | ------ | ---------------------------------------------------- |
37+
| `file` | string | Path to the notebook relative to the repo root |
38+
| `title` | string | Display title shown in the card header |
39+
| `description` | string | One-sentence summary shown in the card body |
40+
41+
Example `notebook_metadata.yml`:
42+
43+
```yaml
44+
- file: tutorials/wise/wise_catalog_search.md
45+
title: WISE Catalog Search
46+
description: Search the AllWISE catalog using astroquery.
47+
- file: tutorials/euclid/1_Euclid_intro_MER_images.md
48+
title: Euclid MER Images
49+
description: Access and visualise Euclid Q1 MER mosaic images.
50+
```
51+
52+
### Directive syntax
53+
54+
````markdown
55+
```{notebook-gallery} notebook_metadata.yml
56+
tutorials/wise/wise_catalog_search.md
57+
tutorials/euclid/1_Euclid_intro_MER_images.md
58+
```
59+
````
60+
61+
- The **argument** (on the opening fence line) is the path to the metadata file.
62+
- The **body** lists one notebook path per line (matching the `file` field in the metadata). Lines starting with `#` are treated as comments.
63+
64+
### Error handling
65+
66+
| Situation | Rendered output |
67+
| ----------------------------------- | -------------------------------------------------------- |
68+
| Metadata file not found / unreadable | An `{error}` admonition with the bad path |
69+
| Notebook path not in metadata | A warning card: _⚠️ Unrecognised notebook_ |

0 commit comments

Comments
 (0)