Created
November 7, 2019 19:21
-
-
Save usulpro/36642bc8f481fc678d61f6b49956f32f to your computer and use it in GitHub Desktop.
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
// lib/contentful-client.js | |
const { createClient } = require("contentful"); | |
const { SPACE, DELIVERY_TOKEN, PREVIEW_TOKEN } = require("./contentful-config"); | |
// const { getLocalMocks } = require('./getLocalMocks'); | |
const isProduction = process.env.NODE_ENV === "production"; | |
// const isLocalMocks = !!process.env.LOCAL; | |
const contentfulClient = createClient({ | |
host: isProduction ? "cdn.contentful.com" : "preview.contentful.com", | |
accessToken: isProduction ? DELIVERY_TOKEN : PREVIEW_TOKEN, | |
space: SPACE, | |
}); | |
const getEntry = entryId => { | |
// if (isLocalMocks) { | |
// const entryData = getLocalMocks(entryId); | |
// return entryData; | |
// } | |
return contentfulClient.getEntry(entryId, { include: 2 }); | |
}; | |
module.exports = { contentfulClient, getEntry }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment