hexo-allery

Plugin for hexo which automatically generates a gallery from images located in the post asset folders, using given layout

Usage no npm install needed!

<script type="module">
  import hexoAllery from 'https://cdn.skypack.dev/hexo-allery';
</script>

README

Hexo allery

This is a plugin for hexo which automatically generates a gallery from images located in the post asset folders, using given layout. It's an modificated version of hexo-tag-autogallery plugin.

Installation

npm install hexo-allery

Configuration

Before using it, you need to create a layout partial that will be used for the gallery. The layout partial must be placed inside the layout/_partial path inside your current theme directory.

A simple example of a template my-theme/layout/_parial/gallery.ejs:

<div class="gallery">
  <% if (photos.length){ %>
    <%
      photos.forEach(function(photo) {
        var path = config.root + photo;
    %>
        <img src="<%-path %>">
    <% }); %>
  <% } %>
</div>

Usage

To use it set the post_asset_folder setting in _config.yml to true.

post_asset_folder: true

Then you should add the tag below to your post.

{% allery layout_name path_to_your_post date %}
Parameters
  • layout-name - the name of the layout to be used. It should be only the filename, without the .ejs extension,
  • images-dir - the post directory,
  • date - the date parameter of the post.
Example
{% allery gallery _posts/first_post 2018/12/12 %}

This will create gallery using the:

  • images from the asset folder of first_post
  • the partial layout themes/current-theme/layout/_partial/gallery.ejs

I strongly recommend using commands hexo generate -f and then hexo server -s, instead of just hexo server.

License

MIT

Gitlab repository