Skip to content

WIP: Add support for gallery highlight images#96

Closed
pleasantone wants to merge 2 commits intohbstack:mainfrom
pleasantone:keyimages
Closed

WIP: Add support for gallery highlight images#96
pleasantone wants to merge 2 commits intohbstack:mainfrom
pleasantone:keyimages

Conversation

@pleasantone
Copy link
Copy Markdown
Contributor

If you have a section/branch page in the gallery, and there is a child page that has images marked as highlight images, display those image in the list page as well. This is used to create a "best of" top level gallery, followed by the standard gallery page links.

Uses .Image.Params.Highlight = True to determine if an image should appear in the parent's page.

With the example hierarchy:

content/gallery
├── 2023-presidents-day
│   ├── _index.md
│   ├── day1
│   │   ├── 441A8531.jpg
│   │   ├── 441A8533.jpg
│   │   ├── 441A8572-featured.jpg
│   │   ├── 441A8712.jpg
│   │   ├── 441A8877.jpg
│   │   ├── 441A8879.jpg
│   │   ├── 441A8889.jpg
│   │   ├── 441A9174.jpg
│   │   ├── index.md
│   │   ├── map_sat.webp
│   ├── day2
│   │   ├── IMG_2194.jpg
│   │   ├── IMG_2199.jpg
│   │   ├── IMG_2960.jpg
│   │   ├── index.md
│   │   ├── map_sun.webp
│   └── day3
│   │   ├── IMG_2294.jpg
│   │   ├── IMG_2299.jpg
│   │   ├── IMG_2060.jpg
│   │   ├── index.md
│   │   └── map_mon.webp
└── _index.en.md

day1/index.md:

resources:
  - src: map_sat.webp
    name: " Day 1 Route Map"
    title: Day 1 Route Map
    params:
      author: Ich
      highlight: true

day2/index.md:

resources:
  - src: map_sun.webp
    name: " Day 2 Route Map"
    title: Day 2 Route Map
    params:
      author: Ich
      highlight: true
  - src: IMG_2961p.jpg
    title: Bull Canyon Rd bridge over the Santa Maria River

Would display 2 highlight images (Day 1 Route Map and Day 2 Route Map) on the gallery/2023-presidents-day/ page followed by the 3 child galleries.

@pleasantone
Copy link
Copy Markdown
Contributor Author

This is, as before, a WIP, we could discuss if we want to format highlight images differently and there are a couple of code cleanup-optimizations that could be done to simplify things.

@razonyang
Copy link
Copy Markdown
Member

No problem, will check this PR tonight.

@razonyang
Copy link
Copy Markdown
Member

Just give it a try, but build fails.

Error: error building site: render: failed to render pages: render of "section" failed: "/home/razon/Workspaces/hbstack/gallery/layouts/gallery/list.html:8:5": execute of template failed: template: gallery/list.html:8:5: executing "main" at <partial "hb/modules/gallery/list" .>: error calling partial: "/home/razon/Workspaces/hbstack/gallery/layouts/partials/hb/modules/gallery/list.html:7:25": execute of template failed: template: partials/hb/modules/gallery/list.html:7:25: executing "partials/hb/modules/gallery/list.html" at <partial "hb/modules/gallery/functions/sorted-page-imgs" .>: error calling partial: "/home/razon/Workspaces/hbstack/gallery/layouts/partials/hb/modules/gallery/functions/sorted-page-imgs.html:2:12": execute of template failed: template: partials/hb/modules/gallery/functions/sorted-page-imgs.html:2:12: executing "partials/hb/modules/gallery/functions/sorted-page-imgs.html" at <partial "hb/modules/gallery/functions/sort-imgs" $imgs>: error calling partial: "/home/razon/Workspaces/hbstack/gallery/layouts/partials/hb/modules/gallery/functions/sort-imgs.html:2:20": execute of template failed: template: partials/hb/modules/gallery/functions/sort-imgs.html:2:20: executing "partials/hb/modules/gallery/functions/sort-imgs.html" at <sort (where $imgs "Date" nil) "Image.Name" "asc">: error calling sort: Image is neither a struct field, a method nor a map element of type interface {}

@pleasantone
Copy link
Copy Markdown
Contributor Author

Odd it built fine for me. Do you have a hierarchy tree I can test against?

@razonyang
Copy link
Copy Markdown
Member

I created and merged a alternative PR #97, please feel free to test with the main branch hugo mod get github.com/hbstack/gallery@main, will draft a new release if there is no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants