Use this plugin to pull data from a Dropbox Paper account into a Gatsby site or application.
-
Run
npm install gatsby-source-dropbox-paper
. -
Get an access token for your Dropbox account, which can be generated here.
-
In your
gatsby-config.js
file, add the plugin and the access token to theplugins
array:
plugins: [
{
resolve: "gatsby-source-dropbox-paper",
options: {
access_token: "your-access-token"
}
]
You're all set!
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"
},
},
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
}
}
}
}
}
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
}
}
}
}
}
}
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.
Please do!
MIT © Alex MacArthur