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

formium-cli

v0.0.0

Published

Placeholder, do not use.

Downloads

4

Readme

gatsby-source-formium

Stable release

Source plugin for pulling forms into Gatsby from Formium projects. It outputs forms (and their schemas) so that they can be safely queried in Gatsby using GraphQL.

Install

npm install --save gatsby-source-formium

How to use

First, you need a way to pass environment variables to the build process, so secrets and other secured data aren’t committed to source control. We recommend using dotenv to expose environment variables safely. Read more about dotenv and using environment variables here. Then we can use these environment variables and configure our plugin.

Once installed, and once you have dotenv setup. Add the plugin to your gatsby-config.js file.

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-formium`,
      options: {
        // Get your projectId from https://dashboard.formium.io
        projectId: process.env.GATSBY_FORMIUM_PROJECTID,
        // Generate a personal access token by going to https://dashboard.formium.io/account#tokens and put it into a .env file (learn more about Gatsby environment variables here: https://gatsby.dev/env-vars).
        accessToken: process.env.FORMIUM_ACCESS_TOKEN,
      },
    },
  ],
};

Plugin configuration options

projectId: string

Required

Formium projectId

accessToken

Required

Formium personal access token. You can generate a personal access token by going to https://dashboard.formium.io/account#tokens.

How to query

You can query nodes created from Formium using GraphQL like the following:

Note: Learn to use the GraphQL tool and Ctrl+Spacebar at http://localhost:8000/___graphql to discover the types and properties of your GraphQL model.

Querying for all forms

To query for all forms in your project:

{
  allFormiumForm {
    edges {
      node {
        id
        name
        slug
        projectId
        schema
        createAt
        updateAt
      }
    }
  }
}

You might do this in your gatsby-node.js using Gatsby's createPages Node API.

Querying for a single form by id

To query for a single form with id of 5f2c1100a46ff8163a9b9f44:

{
  formiumForm(id: { eq: "5f2c1100a46ff8163a9b9f44" }) {
    id
    name
    slug
    projectId
    schema
    createAt
    updateAt
  }
}

You might query for a single form inside a component in your src/components folder, using Gatsby's StaticQuery component.

Querying for a single form by slug

To query for a single form with slug of contact-me:

{
  formiumForm(slug: { eq: "contact-me" }) {
    id
    name
    slug
    projectId
    schema
    createAt
    updateAt
  }
}

You might query for a single form inside a component in your src/components folder, using Gatsby's StaticQuery component.

Create a page for every form in a project

Note: Every form in Formium has a slug. By default, your form's slug is the slugified title of your form. However, you can set a form's slug in the Formium dashboard in your form's Settings tab.

// gatsby-node.js
const path = require('path')

exports.createPages = async ({ graphql, actions }) => {
  const { createPage } = actions

  // Query all Forms
  const pages = await graphql(`
    {
      allFormiumForm {
        edges {
          node {
            id
            slug
          }
        }
      }
    }
  `)

  // The template for your form pages
  const template = path.resolve(__dirname, 'src/templates/form.js'),

  // Create pages for each Form in Prismic using the template.
  pages.data.allFormiumForm.edges.forEach(edge => {
    edge.nodes.forEach((node) => {
      createPage({
        path: `/forms/${node.slug}`,
        component: template,
        context: {
          id: node.id,
          slug: node.slug,
        },
      })
    })
  })
}

Sourcing from multiple Formium projects

To source from multiple Formium projects, add another configuration for gatsby-source-formium in gatsby-config.js:

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-formium`,
      options: {
        projectId: process.env.GATSBY_FORMIUM_PROJECTID,
        accessToken: process.env.FORMIUM_ACCESS_TOKEN,
      },
    },
    {
      resolve: `gatsby-source-formium`,
      options: {
        projectId: process.env.GATSBY_FORMIUM_SECOND_PROJECTID,
        accessToken: process.env.FORMIUM_ACCESS_TOKEN, // assuming you belong to both projects.
      },
    },
  ],
};

You'll also need to create a second Formium client.