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 🙏

© 2025 – Pkg Stats / Ryan Hefner

gridsome-source-static-meta

v1.0.1

Published

Gridsome source to read JSON or YAML objects in static files into GraphQL metaData

Readme

gridsome-source-static-meta

This is a Gridsome source plugin that converts values in JSON and/or YAML files into keys on the global GraphQL metaData query.

What this means in practice is that you can define standard metadata (like siteName or siteUrl) along with custom keys in static JSON or YAML files, and have the values automatically available via standard GraphQL queries. Most projects will not need this. However, if for whatever reason you wish to define static metaData without modifying the gridsome.config.js file, this is an easy method.

Guidelines (read before using!)

When authoring your JSON or YAML metadata files, you must observe the following guidelines:

  • All files must have root-level key/value mappings
  • Arrays cannot mix types
  • Arrays of objects must include all possible keys in the first object in the array (using non-null values)
  • Identical keys in separate files may behave in strange ways; it is best to keep all of your settings in a single file, or at minimum avoid duplicate root-level keys across files.

Failing to observe the above guidlines may result in data in your JSON/YAML files being ignored and missing from GraphQL (see below for why).

Changes to your JSON files will require restarting the server. Gridsome is not currently setup to allow live updating the metaData GraphQL data.

Install

  • yarn add gridsome-source-static-meta
  • npm install gridsome-source-static-meta

Usage

module.exports = {
  plugins: [
    {
      use: 'gridsome-source-static-meta',
      options: {
        path: 'settings/*.json'
      }
    }
  ]
}

Options

path

  • Type: string required

Where to look for files. Should be a glob path.

Possible reasons for missing data in GraphQL

Depending on how you format your files, you may lose data due to the way Gridsome constructs GraphQL types. Please keep the following in mind:

  • You cannot mix data types in arrays, and an array's type is determined by the first element in the array. This means that if you have an array of objects, the first object must include all possible keys (subsequent objects can leave optional keys out, if you wish).
    • The first object in an array must use non-null values for all keys (null keys will be ignored). E.g., if you have an empty string key, your JSON would look like: "stringKey": "". (For subsequent objects you can omit the key, and the GraphQL data will include a null value.)
  • All JSON or YAML files formatted with a root-level arrays will be silently ignored (e.g. if the first character in your JSON file is [ or - in your YAML file, it will be ignored). A key/value mapping is required for all files.
  • Identical keys in separate files will behave as follows (execution order is not guaranteed):
    • Arrays will concatenate (probably poorly, given the restrictions above)
    • Objects will update (adding or overwriting keys as necessary)
    • All other data types will be overwritten