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

gatsby-remark-lottie

v1.0.3

Published

Gatsby remark plugin to embed lottie JSON animations with SVG placeholders

Downloads

38

Readme

Gatsby Remark Lottie Plugin

A Gatsby remark plugin to embed Lottie JSON animations with SVG placeholders in your Markdown/MDX.

Read more about the motivation behind this plugin and a live demo.

Usage

npm install gatsby-remark-lottie

In gatsby-config.js:

module.exports = {
  plugins:[{
    resolve: "gatsby-transformer-remark",
      options: {
        plugins: ["gatsby-remark-lottie"]
      }
  }]
};

or if you are using MDX:

module.exports = {
  plugins:[{
    resolve: "gatsby-plugin-mdx",
      options: {
        gatsbyRemarkPlugins: ["gatsby-remark-lottie"]
      }
  }]
};

Then in your markdown/MDX:

Hi here is a cool animation:

![alt text](myanimation.json)

This assumes a myanimation.json lives next to your markdown/MDX file. The image will then be rendered as a static SVG for clients with scripts disabled and as a placeholder while the animation loads.

If you need some inspiration for JSON animation files, check out Lottie Files.

Options

The plugin takes a number of options that are shown here with their default values:

module.exports = {
  plugins:[{
    resolve: "gatsby-transformer-remark",
      options: {
        plugins: [{
          resolve: "gatsby-remark-lottie",
          options: {
            // Whether or not to generate static SVG placeholders.
            // If this is false, an empty div will render until
            // the lottie script starts the animation.
            generatePlaceholders: true,

            // lottie-web is loaded from CDN to start the animations.
            // This controls which version of the script is loaded.
            lottieVersion: "5.7.1",

            // The renderer to use (html, canvas, or svg). The static
            // placeholder will always be an SVG despite this value.
            // See the lottie-web docs: https://github.com/airbnb/lottie-web#html
            renderer: "svg",

            // Whether or not to loop the animation.
            // See the lottie-web docs: https://github.com/airbnb/lottie-web#html
            loop: true,

            // Whether or not to autoplay the animation on load.
            // See the lottie-web docs: https://github.com/airbnb/lottie-web#html
            autoplay: true
          }
        }]
      }
  }]
};

You can also pass rendererSettings to control lottie-web during the generation of the static placeholder SVG.

How It Works

This plugin makes use of lottie-to-svg to render the first frame of a lottie animation to an SVG which it then places into your HTML. When the page is loaded, the lottie script is loaded from CDN to replace the placeholder with the animation.

Based on the renderer you choose in the plugin's options, only the streamlined script for that renderer will be loaded. e.g. if you choose svg as your renderer, the lottie_svg.min.js file will be loaded.