0.0.3 • Published 3 years ago

eleventy-plugin-sanity-data v0.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

11ty Sanity Data Source

This currently only works in 11ty v1.0.0 (canary). It uses addGlobalData which allows for data plugins like this

Installation

Install the NPM package

npm install eleventy-plugin-sanity-data

Add the plugin to your .eleventy.js config file. Make sure you're running Eleventy v1.0.0+

module.exports = function(config) {
    config.addPlugin(sanityData, {
        projectId: 'YOUR_SANITY_PROJECT_ID'
    });
}

This will return all the data from the project specified.

Configuration

There are configuration options you can use to return different sets of data, different projections, different datasets, and more.

propertytypedescription
projectIdstringYour Sanity.io project ID
cdnbooleanWhether or not to use the Sanity CDN for data
datasetstringThe dataset name for your Sanity data
queriesarraydefault returns allData variable with a query of `[]* An array of objects providing GROQ queries to return specific queries to specific variables. *Optional*. Each object requires avarNameandqueryand has an optionalcacheDurationto override global cache timing.{ varName: 'NameForTemplate', query: '*_type == 'something''`
globalCacheDurationstringdefault: 1d. This is a time string that corresponds to 11ty asset cache plugin times.