feat(lessons): Add lessons modules
This commit is contained in:
committed by
Benedikt Rötsch
parent
1875c99a4c
commit
62ecdfe60c
@@ -2,6 +2,7 @@ const marked = require('marked')
|
|||||||
|
|
||||||
// Parse markdown text
|
// Parse markdown text
|
||||||
exports.markdown = (content) => {
|
exports.markdown = (content) => {
|
||||||
|
content = content || ''
|
||||||
return marked(removeIvalidDataURL(content), {sanitize: true})
|
return marked(removeIvalidDataURL(content), {sanitize: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ exports.getCourse = (slug) => {
|
|||||||
// the SDK support link resolution only when you request the collection endpoint
|
// 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)
|
// 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
|
||||||
return client.getEntries({content_type: 'course', 'fields.slug': slug})
|
return client.getEntries({content_type: 'course', 'fields.slug': slug, include: 10})
|
||||||
.then((response) => response.items[0])
|
.then((response) => response.items[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
extends layout
|
extends layout
|
||||||
|
|
||||||
|
include mixins/_lesson
|
||||||
|
|
||||||
block content
|
block content
|
||||||
.wrapper.wrapper-with-sidebar
|
.wrapper.wrapper-with-sidebar
|
||||||
section.wrapper__sidebar
|
section.wrapper__sidebar
|
||||||
@@ -15,8 +17,7 @@ block content
|
|||||||
h1= course.fields.title
|
h1= course.fields.title
|
||||||
|
|
||||||
if lesson
|
if lesson
|
||||||
h2= lesson.fields.title
|
+lesson(lesson)
|
||||||
p !{helpers.markdown(lesson.fields.description)}
|
|
||||||
if lessonIndex + 1< lessons.length
|
if lessonIndex + 1< lessons.length
|
||||||
a.cta(href=`/courses/${course.fields.slug}/lessons/${lessons[lessonIndex + 1].fields.slug}`) View next lesson
|
a.cta(href=`/courses/${course.fields.slug}/lessons/${lessons[lessonIndex + 1].fields.slug}`) View next lesson
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,7 +1,17 @@
|
|||||||
|
include _lessonModuleCodeSnippet
|
||||||
|
include _lessonModuleCopy
|
||||||
|
include _lessonModuleImage
|
||||||
|
|
||||||
mixin lesson(lesson)
|
mixin lesson(lesson)
|
||||||
.lesson
|
.lesson
|
||||||
h1.lesson__tilte #{lesson.fields.title}
|
h1.lesson__tilte #{lesson.fields.title}
|
||||||
div.lesson__shortDescription !{helpers.markdown(lesson.fields.shortDescription)}
|
div.lesson__shortDescription !{helpers.markdown(lesson.fields.description)}
|
||||||
img.lesson__image(src=`${lesson.fields.image.fields.file.url}` alt=`${lesson.fields.image.fields.title}`)
|
img.lesson__image(src=`${lesson.fields.image.fields.file.url}` alt=`${lesson.fields.image.fields.title}`)
|
||||||
|
each module in lesson.fields.modules
|
||||||
|
case module.sys.contentType.sys.id
|
||||||
|
when 'lessonModuleCodeSnippets'
|
||||||
|
+lessonModuleCodeSnippet(module)
|
||||||
|
when 'lessonModuleCopy'
|
||||||
|
+lessonModuleCopy(module)
|
||||||
|
when 'lessonModuleImage'
|
||||||
|
+lessonModuleImage(module)
|
||||||
15
views/mixins/_lessonModuleCodeSnippet.pug
Normal file
15
views/mixins/_lessonModuleCodeSnippet.pug
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
mixin lessonModuleCodeSnippet(module)
|
||||||
|
.lessonModule
|
||||||
|
.lessonModule__code
|
||||||
|
h1.lessonModule__title #{module.fields.title}
|
||||||
|
pre.lessonModule__code__curl !{helpers.markdown(module.fields.curl)}
|
||||||
|
pre.lessonModule__code__dotnet !{helpers.markdown(module.fields.dotNet)}
|
||||||
|
pre.lessonModule__code__javascript !{helpers.markdown(module.fields.javascript)}
|
||||||
|
pre.lessonModule__code__java !{helpers.markdown(module.fields.java)}
|
||||||
|
pre.lessonModule__code__javaAndroid !{helpers.markdown(module.fields.javaAndroid)}
|
||||||
|
pre.lessonModule__code__php !{helpers.markdown(module.fields.php)}
|
||||||
|
pre.lessonModule__code__python !{helpers.markdown(module.fields.python)}
|
||||||
|
pre.lessonModule__code__ruby !{helpers.markdown(module.fields.ruby)}
|
||||||
|
pre.lessonModule__code__swift !{helpers.markdown(module.fields.swift)}
|
||||||
|
|
||||||
|
|
||||||
5
views/mixins/_lessonModuleCopy.pug
Normal file
5
views/mixins/_lessonModuleCopy.pug
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
mixin lessonModuleCopy(module)
|
||||||
|
.lessonModule
|
||||||
|
.lessonModule__copy
|
||||||
|
h1.lessonModule__copy__title #{module.fields.title}
|
||||||
|
.lessonModule__copy__copy !{helpers.markdown(module.fields.copy)}
|
||||||
5
views/mixins/_lessonModuleImage.pug
Normal file
5
views/mixins/_lessonModuleImage.pug
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
mixin lessonModuleImage(module)
|
||||||
|
.lessonModule
|
||||||
|
.lessonModule__image
|
||||||
|
h1.lessonModule__image__title #{module.fields.title}
|
||||||
|
img.lessonModule__image__image(src=module.fields.file.url alt=module.fields.title)
|
||||||
Reference in New Issue
Block a user