_slug.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div>
  3. <product-hero
  4. :title="course.title"
  5. :subtitle="course.subtitle"
  6. :author="course.author">
  7. <product-hero-card
  8. :price="course.price"
  9. :discountedPrice="course.discountedPrice"
  10. :navigateTo="course.productLink"
  11. :requirements="course.requirements"
  12. :image="course.image" />
  13. </product-hero>
  14. <div class="container">
  15. <div class="columns">
  16. <div class="column is-9">
  17. <div class="section">
  18. <div class="what-you-get">
  19. <div class="what-you-get-title">
  20. What you will learn
  21. </div>
  22. <ul class="what-you-get-items">
  23. <!-- TODO: Iterate course wsl -->
  24. <li
  25. v-for="wsl in course.wsl"
  26. :key="wsl.value"
  27. class="what-you-get-item">
  28. <span>{{wsl.value}}</span>
  29. </li>
  30. </ul>
  31. </div>
  32. </div>
  33. <div class="section course-description p-t-none">
  34. <div class="course-description-title">Course Info</div>
  35. <div class="course-description-details">
  36. <!-- TODO: use v-html for description -->
  37. <div v-html="course.description"></div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import ProductHero from '~/components/ProductHero'
  47. import ProductHeroCard from '~/components/ProductHeroCard'
  48. export default {
  49. head() {
  50. return {
  51. title: this.course.title,
  52. meta: [
  53. { hid: 'description', name: 'description', content: this.course.subtitle }
  54. ]
  55. }
  56. },
  57. components: {
  58. ProductHero, ProductHeroCard
  59. },
  60. computed: {
  61. course() {
  62. return this.$store.state.course.item
  63. }
  64. },
  65. async fetch({store, params}) {
  66. await store.dispatch('course/fetchCourseBySlug', params.slug)
  67. }
  68. }
  69. </script>
  70. <!-- Fetch course by Slug -->
  71. <!-- 1. create action "fetchCourseBySlug" in store/course.js -->
  72. <!-- 2. send GET request '/api/v1/products/s/:slug' -->
  73. <!-- 3. expect to receive "course" in "then" and commit it to state -->
  74. <!-- 4. get course in computed properties -->
  75. <!-- 5. Complete TODO's -->
  76. <!-- 6. Navigate to detail page from home page when clicking on "Learn More" -->
  77. <style lang="scss">
  78. .what-you-get {
  79. background-color: #f9f9f9;
  80. border: 1px solid #dedfe0;
  81. padding: 10px 15px;
  82. &-title {
  83. font-size: 26px;
  84. font-weight: bold;
  85. margin-bottom: 10px;
  86. }
  87. &-items {
  88. display: flex;
  89. align-items: flex-start;
  90. justify-content: space-between;
  91. flex-wrap: wrap;
  92. }
  93. &-item {
  94. display: flex;
  95. align-items: center;
  96. margin-bottom: 10px;
  97. font-size: 17px;
  98. width: 45%;
  99. }
  100. }
  101. .course-description {
  102. &-title {
  103. font-size: 26px;
  104. font-weight: bold;
  105. margin-bottom: 10px;
  106. }
  107. &-details {
  108. font-size: 18px;
  109. ul {
  110. list-style: disc;
  111. margin-left: 20px;
  112. }
  113. ol {
  114. margin-left: 20px;
  115. }
  116. strong {
  117. font-size: 20px;
  118. }
  119. p {
  120. min-height: 30px;
  121. }
  122. }
  123. }
  124. </style>