Skip to content

Instantly share code, notes, and snippets.

@anithegregorian
Last active February 22, 2021 16:57
Show Gist options
  • Save anithegregorian/5ff3626e4cb8961494b8054d7705e14d to your computer and use it in GitHub Desktop.
Save anithegregorian/5ff3626e4cb8961494b8054d7705e14d to your computer and use it in GitHub Desktop.
Contentful plugin configuration in NuxtJS
/* eslint eol-last: ["error", "always"] */
const contentful = require('contentful')
// Those are set via `env` property in nuxt.config.js or environment variables
const config = {
space: process.env.NUXT_ENV_CONTENTFUL_SPACE,
accessToken: process.env.NUXT_ENV_CONTENTFUL_ACCESS_TOKEN
}
// Create a client to setup fetching content
// const client = contentful.createClient(config)
//
// // Our first method to fetch all section content type
// client.getSectionContent = () =>
// client.getEntries('', {
// content_type: 'Blog'
// })
//
// export default ({ app }) => {
// // Add the function directly to the context.app object
// app.contentfulClient = client
// }
module.exports = {
createClient () {
return contentful.createClient(config)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment