feat: Order courses by date DESC
This commit is contained in:
committed by
Benedikt Rötsch
parent
2ec0cf9d67
commit
6d55102c16
@@ -27,14 +27,24 @@ exports.getCourses = assert((locale = 'en-US', api = `cda`) => {
|
|||||||
// to get all the courses we request all the entries
|
// to get all the courses we request all the entries
|
||||||
// with the content_type `course` from Contentful
|
// with the content_type `course` from Contentful
|
||||||
const client = api === 'cda' ? cdaClient : cpaClient
|
const client = api === 'cda' ? cdaClient : cpaClient
|
||||||
return client.getEntries({content_type: 'course', locale, include: 10})
|
return client.getEntries({
|
||||||
|
content_type: 'course',
|
||||||
|
locale,
|
||||||
|
order: 'sys.createdAt',
|
||||||
|
include: 10
|
||||||
|
})
|
||||||
.then((response) => response.items)
|
.then((response) => response.items)
|
||||||
}, 'Course')
|
}, 'Course')
|
||||||
|
|
||||||
exports.getLandingPage = (slug, locale = 'en-US', api = `cda`) => {
|
exports.getLandingPage = (slug, locale = 'en-US', api = `cda`) => {
|
||||||
// Landing pages like the home or about page are fully controlable via Contentful.
|
// Landing pages like the home or about page are fully controlable via Contentful.
|
||||||
const client = api === 'cda' ? cdaClient : cpaClient
|
const client = api === 'cda' ? cdaClient : cpaClient
|
||||||
return client.getEntries({content_type: 'landingPage', locale, 'fields.slug': slug, include: 10})
|
return client.getEntries({
|
||||||
|
content_type: 'landingPage',
|
||||||
|
locale,
|
||||||
|
'fields.slug': slug,
|
||||||
|
include: 10
|
||||||
|
})
|
||||||
.then((response) => response.items[0])
|
.then((response) => response.items[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +53,12 @@ exports.getCourse = assert((slug, locale = 'en-US', api = `cda`) => {
|
|||||||
// That's why we are using getEntries with a query instead of getEntry(entryId)
|
// That's why we are using getEntries with a query instead of getEntry(entryId)
|
||||||
// make sure to specify the content_type whenever you want to perform a query
|
// make sure to specify the content_type whenever you want to perform a query
|
||||||
const client = api === 'cda' ? cdaClient : cpaClient
|
const client = api === 'cda' ? cdaClient : cpaClient
|
||||||
return client.getEntries({content_type: 'course', 'fields.slug': slug, locale, include: 10})
|
return client.getEntries({
|
||||||
|
content_type: 'course',
|
||||||
|
'fields.slug': slug,
|
||||||
|
locale,
|
||||||
|
include: 10
|
||||||
|
})
|
||||||
.then((response) => response.items[0])
|
.then((response) => response.items[0])
|
||||||
}, 'Course')
|
}, 'Course')
|
||||||
|
|
||||||
@@ -59,6 +74,7 @@ exports.getCoursesByCategory = assert((category, locale = 'en-US', api = `cda`)
|
|||||||
content_type: 'course',
|
content_type: 'course',
|
||||||
'fields.categories.sys.id': category,
|
'fields.categories.sys.id': category,
|
||||||
locale,
|
locale,
|
||||||
|
order: '-sys.createdAt',
|
||||||
include: 10
|
include: 10
|
||||||
})
|
})
|
||||||
.then((response) => response.items)
|
.then((response) => response.items)
|
||||||
|
|||||||
Reference in New Issue
Block a user