feat(courses): Add Landing Page content modules

This commit is contained in:
Khaled Garbaya
2017-09-26 14:35:53 +02:00
committed by Benedikt Rötsch
parent e2ceb39e83
commit 0c66b6678c
10 changed files with 68 additions and 10 deletions

View File

@@ -7,12 +7,19 @@ exports.initClient = (config = {space: process.env.CF_SPACE, accessToken: proces
client = createClient(config)
previewClient = createClient({...config, host: 'preview.contentful.com'})
}
exports.getCourses = () => {
// to get all the courses we simply request from Contentful all the entries
// with the content_type `course`
return client.getEntries({content_type: 'course'})
}
exports.getLandingPage = () => {
// our Home page is fully configureable via contentful
return client.getEntries({content_type: 'landingPage', 'fields.slug': 'contentful-university'})
.then((response) => response.items[0])
}
exports.getCourse = (slug) => {
// the SDK support link resolution only when you request the collection endpoint
// That's why we are using getEntries with a query instead of getEntry(entryId)