Last active
February 22, 2021 16:57
-
-
Save anithegregorian/5ff3626e4cb8961494b8054d7705e14d to your computer and use it in GitHub Desktop.
Contentful plugin configuration in NuxtJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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