Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @nteract/gatsby-transformer-ipynb with all npm packages installed. Try it out:

var gatsbyTransformerIpynb = require("@nteract/gatsby-transformer-ipynb")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@nteract/gatsby-transformer-ipynb v2.0.3

Gatsby transformer plugin for jupyter notebooks

gatsby-transformer-ipynb

Parses jupyter notebook files.

See it in action: https://gatsby-contrib.github.io/gatsby-transformer-ipynb/

Install

npm install --save @nteract/gatsby-transformer-ipynb

How to use

// In your gatsby-config.js
plugins: [`@nteract/gatsby-transformer-ipynb`];

Parsing algorithm

It recognizes files with the ipynb extension.

Each notebook file is parsed into a node of type JupyterNotebook.

This plugin adds additional fields to the JupyterNotebook GraphQL type including:

  • html: html string created using the react component NotebookRender from @nteract/notebook-render.
  • metadata: jupyter notebooks can embed metadata to indicate authors, titles...
  • json: the json notebook code converted into a javascript object with JSON.parse.
  • internal.content: contains the raw notebook code, it can be used to feed the react component NotebookPreview from @nteract/notebook-preview.

How to query

A sample GraphQL query to get JupyterNotebook nodes:

{
  query
  JupyterQuery {
    allJupyterNotebook {
      edges {
        node {
          id
          metadata {
            kernelspec {
              name
              language
              display_name
            }
          }
          html
          json {
            nbformat
            nbformat_minor
            cells {
              cell_type
              execution_count
            }
          }
          internal {
            content
          }
        }
      }
    }
  }
}

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free