Coder Social home page Coder Social logo

schnouki / hugo-baguettebox Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 1.0 17 KB

A Hugo theme component that provides an image gallery and lightbox powered by baguetteBox.js.

License: MIT License

Makefile 14.72% HTML 85.28%
hugo hugo-theme-component gallery lightbox baguettebox

hugo-baguettebox's Introduction

hugo-baguetteBox

This is a theme component for Hugo. It provides shortcodes to include an image gallery and lightbox powered by baguetteBox.js in a Hugo website.

Installation

Clone this git repository into your themes folder (or add it as a submodule if you're already using git):

git clone https://github.com/Schnouki/hugo-baguetteBox themes/baguettebox

Now add this theme component to your config.toml:

theme = ["baguettebox", "main-theme"]

Usage

In a post or page, you can add a gallery using the {{< gallery >}} shortcode, and images inside the gallery using the {{< galimg >}} shortcode:

{{< gallery >}}
  {{% galimg target="image01.png" title="This image has a title but no caption!" /%}}
  {{% galimg target="image02.png" %}}This image has a caption!{{% /galimg %}}
  {{% galimg target="image03.png" thumb="image03_thumb.png" %}}Don't generate the thumbnail for this one, use an existing file.{{% /galimg %}}
  {{% galimg target="image04.png" size="400x300" %}}Use a different size for the thumbnail…{{% /galimg %}}
  {{% galimg target="image05.png" size="400x300 BottomLeft q90 r90" %}}You can actually use any option supported by Hugo's image processing.{{% /galimg %}}
  {{% galimg target="image06.png" mode="resize" size="100x20" %}}You can also choose the image processing method.{{% /galimg %}}
{{< /gallery >}}

As can be seen, the gallery shortcode does not accept any parameter.

The galimg shortcode, however, accepts several parameters:

  • target (required): name for the full-size image
  • thumb (optional): name of the thumbnail. If missing, the thumbnail will be generated by Hugo using its image processing.
  • size (optional): size for the generated thumbnail. This can actually be any valid image processing option. Defaults to 200x150 smart.
  • mode (optional): method used to generate the thumbnail. Can be fill, fit or resize. Defaults to fill.

Gallery appearance

This component does not include a stylesheet for the gallery, you will need to add this to your site by yourself.

The generated HTML is very simple:

<div class="gallery">
  <a href="/path/to/fullsize-image.jpg" data-caption="Image caption" title="Image title">
    <img src="/path/to/thumbnail.jpg alt="Image title" />
  </a>
</div>

Here is a sample CSS that works well with the Minimo theme:

.gallery {
    display: flex;
    flex-flow: row wrap;
    justify-content: space-around;
}
.gallery a {
    border: 0;
    margin-bottom: .5em;
}
.gallery img {
    border: .125em solid #bdbdbd;
}

Dependencies

This components includes baguetteBox.js, which is very small (less that 10 kB of JavaScript and 4 kB of CSS). It is only included on pages that need it, and has no external dependency at all.

To customize how it is loaded, you can overload the gallery/resources.html partial template. This way you can for instance load it from a CDN (instead of using the bundled version), or disable fingerprintint, or use Hugo Pipes to enable PostCSS or whatever you want.

hugo-baguettebox's People

Contributors

schnouki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

subkultur

hugo-baguettebox's Issues

Error in Hugo v0.55.6

I've enable this on config.toml after cloning it to themes and I get this when I try to use a gallery:

Total in 56 ms
Error: Error building site: "/home/sardaukar/Code/OWN/hugo/blogV2/content/post/amiga-bbs-online-2019.md:7:1": failed to render shortcode "gallery": failed to process shortcode: "/home/sardaukar/Code/OWN/hugo/blogV2/themes/hugo-baguetteBox/layouts/shortcodes/galimg.html:8:36": execute of template failed: template: shortcodes/galimg.html:8:36: executing "shortcodes/galimg.html" at <$img.Fill>: nil pointer evaluating resource.Resource.Fill

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.