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-source-roamresearch

v0.4.5

Published

Source plugin for pulling data into Gatsby from Roam Research

Downloads

47

Readme

gatsby-source-roamresearch

Source plugin for pulling data into Gatsby from Roam Research. It creates links between pages so they can be queried in Gatsby using GraphQL.

An example site for using this plugin is at https://mathieudutour.github.io/gatsby-digital-garden/

Install

npm install --save gatsby-source-roamresearch

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 which will then expose environment variables. Read more about dotenv and using environment variables here. Then we can use these environment variables and configure our plugin.

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-roamresearch`,
      options: {
        url: `https://roamresearch.com/#/app/YOUR_DATABASE_HERE`,
        // Learn about environment variables: https://gatsby.dev/env-vars
        email: process.env.ROAM_RESEARCH_EMAIL,
        password: process.env.ROAM_RESEARCH_PASSWORD,
      },
    },
  ],
};

Configuration options

url [string][required]

Url to the Roam Research database

email [string][required]

Email used to sign into Roam Research

password [string][required]

Password used to sign into Roam Research

How to query for nodes

Two standard node types are available from Roam Research: Page and Block.

The nodes will be created in your site's GraphQL schema under roam${entryTypeName} and allRoam${entryTypeName}.

In all cases querying for nodes like roamX will return a single node, and nodes like allRoamX will return all nodes of that type.

Query for all nodes

You might query for all of a type of node:

{
  allRoamPage {
    nodes {
      id
      title
    }
  }
}

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

Query for a single node

To query for a single block with the id 'foo':

export const blockQuery = graphql`
  {
    roamBlock(id: "foo") {
      string
    }
  }
`;

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

A note about markdown fields

Roam Research uses Markdown for its formatting.

In order to handle the Markdown content, you must use a transformer plugin such as gatsby-transformer-remark or gatsby-plugin-mdx. The transformer will create a childMarkdownRemark field on the node and expose the generated html as a child node:

{
  roamBlock {
    childMarkdownRemark {
      html
    }
  }
}

You can then insert the returned HTML inline in your JSX:

<div
  className="body"
  dangerouslySetInnerHTML={{
    __html: data.roamBlock.childMarkdownRemark.html,
  }}
/>

Note that Roam Research uses some non-standard syntax for its internal links, so you will need some additional plugins to handle them (for example gatsby-remark-double-brackets-link and gatsby-remark-double-parenthesis-link).

In order to extract the references between the nodes, you can use gatsby-transformer-markdown-references.

Sourcing From Multiple Roam Research databases

To source from multiple Roam Research databases, add another configuration for gatsby-source-roamresearch in gatsby-config.js:

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-roamresearch`,
      options: {
        url: `https://roamresearch.com/#/app/YOUR_DATABASE_HERE`,
        email: process.env.ROAM_RESEARCH_EMAIL,
        password: process.env.ROAM_RESEARCH_PASSWORD,
      },
    },
    {
      resolve: `gatsby-source-roamresearch`,
      options: {
        url: `https://roamresearch.com/#/app/YOUR_SECOND_DATABASE_HERE`,
        email: process.env.ROAM_RESEARCH_SECOND_EMAIL,
        password: process.env.ROAM_RESEARCH_SECOND_PASSWORD,
      },
    },
  ],
};