Skip to content

alexmacarthur/gatsby-source-dropbox-paper

Repository files navigation

Dropbox Paper Source Plugin for Gatsby

Use this plugin to pull data from a Dropbox Paper account into a Gatsby site or application.

Installation

  1. Run npm install gatsby-source-dropbox-paper.

  2. Get an access token for your Dropbox account, which can be generated here.

  3. In your gatsby-config.js file, add the plugin and the access token to the plugins array:

plugins: [
    {
        resolve: "gatsby-source-dropbox-paper",
        options: {
            access_token: "your-access-token"
    }
]

You're all set!

Usage

Setting Output Format

By default, data will be pulled in Markdown format, but you may also specify "html" by including a format option:

plugins: [
    'gatsby-plugin-react-helmet',
    {
        resolve: "gatsby-source-dropbox-paper",
        options: {
            access_token: "your-access-token",
            format: "html"
    },
},

Querying for Data

You can use the following GraphQL fields to pull raw data into your pages.

{
  allDropboxPaperDocument(limit: 10) {
    edges {
      node {
        content
        doc_id
        owner
        title
        created_date
        status {
          _tag
        }
        revision
        last_updated_date
        last_editor
        id
        internal {
          type
          content
          contentDigest
          owner
        }
      }
    }
  }
}

Get Transformed Markdown

Using the gatsby-transformer-remark plugin, you can access pulled Markdown transformed into HTML. Simply use the childMarkdownRemark field when querying for data.

{
  allDropboxPaperDocument(limit: 10) {
    edges {
      node {
        childMarkdownRemark {
          id
          html
          excerpt
          timeToRead
          wordCount {
            paragraphs
            sentences
            words
          }
        }
      }
    }
  }
}

The Future

Right now, this plugin pulls all documents from an authenticated account, which is less than ideal. Improvements will come with changes to this plugin, as well as the evolution of the Dropbox API, which has limited capabilities in terms of filtering documents to be pulled. Here's what I'd like to see in the future:

  • The ability pull documents by status.
  • The ability to pull documents by specific directory.
  • Other stuff.

Contributions

Please do!

License

MIT © Alex MacArthur