Update the gallery page.
(app: Sphinx)
| 395 | |
| 396 | |
| 397 | def update_gallery(app: Sphinx): |
| 398 | """Update the gallery page.""" |
| 399 | |
| 400 | LOGGER.info("Updating gallery page...") |
| 401 | |
| 402 | gallery = yaml.safe_load(pathlib.Path(app.srcdir, "gallery.yml").read_bytes()) |
| 403 | |
| 404 | for key in gallery: |
| 405 | items = [ |
| 406 | f""" |
| 407 | .. grid-item-card:: |
| 408 | :text-align: center |
| 409 | :link: {item['path']} |
| 410 | |
| 411 | .. image:: {item['thumbnail']} |
| 412 | :alt: {item['title']} |
| 413 | +++ |
| 414 | {item['title']} |
| 415 | """ |
| 416 | for item in gallery[key] |
| 417 | ] |
| 418 | |
| 419 | items_md = indent(dedent("\n".join(items)), prefix=" ") |
| 420 | markdown = f""" |
| 421 | .. grid:: 1 2 2 2 |
| 422 | :gutter: 2 |
| 423 | |
| 424 | {items_md} |
| 425 | """ |
| 426 | pathlib.Path(app.srcdir, f"{key}-gallery.txt").write_text(markdown) |
| 427 | LOGGER.info(f"{key} gallery page updated.") |
| 428 | LOGGER.info("Gallery page updated.") |
| 429 | |
| 430 | |
| 431 | def update_videos(app: Sphinx): |