npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

von-gallery

v3.0.7

Published

Elegant single page gallery generator.

Downloads

4

Readme

npm npm Build Status

🖼️🤔 Node.js generator for (static) single page galleries. The default template is responsive and supports lazy loading. Available as a CommonJS module and as a command line tool.

Building a single page gallery using just the von command:

The concept behind Von.

Example usage

Install Node.js, which will automatically install NPM. Then, install Von globally:

npm install -g von-gallery

Now go into any folder on your computer with some images, open a terminal window, and simply run:

von -r

Where -r stands for "recursive". This will create an index.html file with a gallery of all of the images in that folder. By default, Von groups images either using their directory or prefix (e.g. prefix-my_image.jpg), but you can adjust this behaviour.

About

Von was meant to be very simple to use. Most of the time, von command will be all you need. You can also specify some extra options - this can all be done by passing command line arguments to von, for example:

von -o ./build/output.html -tp ./custom-template.pug --recursive

Alternatively, you can create a config file called vonrc.js. The config lets you do anything that command line arguments can do, plus a little extra. Namely, you can use the config to define groups and custom grouping/sorting functions. Once you have defined a config, simply run von in the same directory. Check out this example config for more info.

If you want to automate the process even further, you can add von-gallery as a dependency to your NPM project and use it as a CommonJS module, for example:

const Von = require('von-gallery');

// Specify options for Von
let options = {
    directory: './path/to/images/',
    output: './build/my-gallery.html',
    template: 'mini',
    groupOrder: 'desc',
};

// Only generate a schema, without actually creating any new files:
let schema = Von.generateSchema(options);
console.log(schema);

// Build a single page gallery and store in the specified `output` file:
Von.run(options);

In fact, the command line tool is simply a wrapper around this module, so both offer identical functionality.

Remember that Von is a single page gallery generator - if you want to develop something complex you should use a proper static site generator.

How Von works

There are 4 components Von works with:

  1. Images. Images are the actual files located in the folder Von is working with.
  2. Groups. Groups are collection of images. You tell Von which heuristics to use to group images by specifying either command line arguments or config properties.
  3. Schema. Schema contains information about your gallery. This includes the page title, page description, array of all groups, and other arbitrary information. You can append extra information to it using the config.
  4. Template. Template uses the schema created in the previous step to produce HTML for your gallery. Currently Von uses mini as the default template, but you can also define custom templates.

The logic Von executes can be separated into two distinct steps: schema generation and template compilation.

Phase 1: Schema generation

No new files are created during this phase. First, Von scans the working directory for images. Once all of the images have been discovered, they are grouped and sorted using the options you specified. Then, said groups, images and options are used to generate a schema object which describes your gallery.

This new schema is an independent piece of data. In fact, you don't even have to proceed to the next step - you can simply export the schema using the von -s command or Von.generateSchema({...}) function. The former might be useful for debugging your vonrc.js.

Phase 2: Template compilation

During this phase Von takes the generated schema and uses it to build the template you chose. At the moment, the only built-in template is mini but you can specify your own templates.

There is a built-in support for Pug templates, so you can simply point Von at a Pug file using von -tp ./path/to/template.pug. If you use Pug, the schema object will be available in your Pug code. For example, you can use schema.title and schema.description to access the title and the description of the gallery respectively.

If you want to use some other templating engine, you can define a my-template.von.js, where my-template is the name of your template. Then, you can tell Von to use it by specifying the appropriate command line arguments:

von -tp ./path/to/my-template.von.js

Von will initialise your template and call the .compile() method letting you handle the rest of the logic. See mini.von.js for example implementation.

Finally, built-in Von templates will write HTML out to the output file you specified. Note that your custom template can override this logic: it can write out to a different file, to multiple files or not write anything at all.