Plan to Fix Duplicate Categories and Refactor Gallery
Plan to Fix Duplicate Categories and Refactor Gallery
This plan outlines the steps to resolve the duplicate category issue and refactor the gallery page.
Part 1: Fix Duplicate Categories (Completed)
- Status: Done.
- Summary: Created
.customversions of_includes/posts-taxonomy.htmland_layouts/categories.html, and updatedcategories.mdto use the new layout. This ensures the category list is generated from a unique, sorted list of categories.
Part 2: Refactor the Gallery Page
1. Analysis and Strategy
- Issue: The current gallery at
/gallery/is described as “extremely bad”. The user wants a responsive, Pinterest-like waterfall layout with a feature-rich lightbox (including image descriptions and download/like buttons). - Current State: The page uses Masonry.js combined with a significant amount of custom JavaScript for loading logic and a basic lightbox. This solution is complex and lacks the desired features.
- Strategy: Replace the custom implementation with
lightGallery.js, a powerful all-in-one library that provides both a masonry grid layout (via a plugin) and a highly customizable lightbox with features like zoom, thumbnails, and download buttons. This will result in a more robust, feature-rich, and easier-to-maintain solution.
2. Detailed Implementation Plan
Step 2.1: Clean Up Existing Implementation
- File:
_layouts/gallery.html- Action: Remove the
<script>tag formasonry.pkgd.min.js. - Action: Remove the custom lightbox HTML (
<div class="gallery-lightbox" ...>).
- Action: Remove the
- File:
assets/js/gallery.js- Action: Delete the entire content of this file, as all its logic will be replaced.
- File:
_sass/minimal-mistakes/_gallery.scss- Action: Remove the styles related to the custom lightbox (
.gallery-lightbox,.lightbox-overlay, etc.). The grid styles can be partially reused.
- Action: Remove the styles related to the custom lightbox (
Step 2.2: Enhance Data Structure
- File:
_data/gallery.yml- Action: Propose and document a slightly extended data structure to support new lightbox features. The new structure will include fields for a detailed description and a download link.
- Example New Entry:
```yaml
- url: /assets/images/gallery/thumb.jpg full_url: /assets/images/gallery/full.jpg alt: “Image Alt Text” caption: “Short Caption” description: “This is a longer, more detailed description for the lightbox.” download_url: /assets/images/gallery/full.jpg ```
Step 2.3: Rebuild the Gallery Layout
- File:
_layouts/gallery.html- Action: Since this file has the ‘gallery’ keyword, I will modify it directly.
- Action: Add the CDN links for
lightGallery.jsCSS, JS, and required plugins (like masonry, zoom, thumbnails, download) in the<head>or at the bottom of the file. - Action: Rewrite the
forloop to generate the HTML structure required bylightGallery. This involves wrapping each image in an<a>tag and usingdata-attributes for the full image URL and the description.
Step 2.4: Implement JavaScript Initialization
- File:
assets/js/gallery.custom.js(New File)- Action: Create this new file.
- Action: Write the JavaScript code to initialize
lightGalleryon the gallery container. This will include enabling the masonry, zoom, thumbnails, and download plugins.
- File:
_layouts/gallery.html- Action: Add a
<script>tag to load the newassets/js/gallery.custom.js.
- Action: Add a
Step 2.5: Style the New Gallery
- File:
_sass/minimal-mistakes/_gallery.scss- Action: Modify the existing styles to work with the new
lightGallerystructure. Ensure the gallery is responsive and visually appealing, matching the “Pinterest-like” aesthetic. The file name contains “gallery”, so I can modify it directly.
- Action: Modify the existing styles to work with the new
3. Verification
- Action: After implementing the changes, run
bundle exec jekyll serveand check the/gallery/page. - Expected Outcome:
- The gallery displays as a responsive, waterfall grid.
- Clicking an image opens a modern lightbox.
- The lightbox displays the image, a detailed description, thumbnails for navigation, and a download button.
- The gallery is easy to update by simply adding new entries to
_data/gallery.yml.