Socket
Socket
Sign inDemoInstall

gatsby-theme-blog-sanity

Package Overview
Dependencies
15
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gatsby-theme-blog-sanity

A Gatsby theme to pull blog posts from Sanity.io. This theme doesn’t provide much by way of styling, but it’s hooked up to [`theme-ui`’s Gatsby plugin](https://theme-ui.com/gatsby-plugin) for easy style overrides.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
21.7 MB
Created
Weekly downloads
 

Readme

Source

gatsby-theme-blog-sanity

A Gatsby theme to pull blog posts from Sanity.io. This theme doesn’t provide much by way of styling, but it’s hooked up to theme-ui’s Gatsby plugin for easy style overrides.

To install:

# in your Gatsby project, install the theme
yarn add gatsby-theme-blog-sanity

Set up your environment variables in .env.development:

# get these values from manage.sanity.io
# REQUIRED
GATSBY_SANITY_PROJECT_ID=xxx
GATSBY_SANITY_DATASET=production

# OPTIONAL — set this if you want live draft updates
SANITY_TOKEN=xxx

In your gatsby-config.js:

// see https://www.gatsbyjs.org/docs/environment-variables/
require('dotenv').config({
  path: `.env.${process.env.NODE_ENV}`
});

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-theme-blog-sanity',
      options: {
        sanity: {
          // get these values from manage.sanity.io
          projectId: process.env.GATSBY_SANITY_PROJECT_ID,
          dataset: process.env.GATSBY_SANITY_DATASET,

          // optional — set this if you want live draft updates
          token: process.env.SANITY_TOKEN,
        }
      }
  ]
}

Options

optiondefaultdescription
basePath/the path where the blog should be created (e.g. /blog)
baseUrlwindow.location.originURL used for SEO tags
includePathInPoststrueif false, blog posts will not include the basePath (e.g. /my-post); by default, posts include the basePath (e.g. /blog/my-post)
sanity.projectIdthe Sanity project ID from Sanity Studio
sanity.datasetthe Sanity dataset (usually "production" by default)
sanity.tokena Sanity read token (see your API settings)
sanity.watchModetrue in develop if token is set, else falsewhen true, updates the UI in real time during development
sanity.overlayDraftstrue in develop, false in productionwhen true, displays draft content

The sanity options are passed directly through to gatsby-source-sanity. See the docs for additional information on what these options mean.

Kitchen sink example

In your gatsby-config.js:

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-theme-blog-sanity',
      options: {
        basePath: '/blog',
        baseUrl: 'https://example.com',
        sanity: {
          projectId: 'xxx',
          dataset: 'production',
          token: 'xxx',
          watchMode: true,
          overlayDrafts: false,
        }
      }
    }
  ]
}

Keywords

FAQs

Last updated on 23 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc