index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div>
  3. <div class="main-content">
  4. <div class="container">
  5. <div class="columns is-mobile">
  6. <!-- posts -->
  7. <div class="column is-8">
  8. <div
  9. v-for="blog in publishedBlogs"
  10. :key="blog._id"
  11. class="section">
  12. <div class="post">
  13. <div @click="$router.push(`/blogs/${blog.slug}`)" class="post-header clickable">
  14. <h4 class="title is-4">{{blog.title}}</h4>
  15. <h5 class="subtitle is-5">{{blog.subtitle}}</h5>
  16. </div>
  17. <div class="post-content">
  18. by {{blog.author.name}}, {{blog.createdAt | formatDate}}
  19. </div>
  20. </div>
  21. </div>
  22. <!-- end of blog -->
  23. <!-- pagination -->
  24. <div class="section">
  25. <no-ssr placeholder="Loading...">
  26. <paginate
  27. :page-count="pagination.pageCount"
  28. :click-handler="handleClick"
  29. :prev-text="'Prev'"
  30. :next-text="'Next'"
  31. :container-class="'paginationContainer'">
  32. </paginate>
  33. </no-ssr>
  34. </div>
  35. <!-- end of pagination -->
  36. </div>
  37. <!-- side bar -->
  38. <div class="column is-4 is-narrow">
  39. <!-- featured -->
  40. <div class="section">
  41. <div class="sidebar">
  42. <div class="sidebar-header">
  43. <h4 class="title is-4">Featured Posts</h4>
  44. </div>
  45. <div class="sidebar-list">
  46. <!-- Featured Blogs -->
  47. <p
  48. v-for="fBlog in featuredBlogs"
  49. :key="fBlog._id">
  50. <nuxt-link :to="`/blogs/${fBlog.slug}`">
  51. {{fBlog.title}}
  52. </nuxt-link>
  53. </p>
  54. <!-- Featured Blogs -->
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <!-- end of side bar -->
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import { mapState } from 'vuex';
  67. export default {
  68. computed: {
  69. ...mapState({
  70. publishedBlogs: state => state.blog.items.all,
  71. featuredBlogs: state => state.blog.items.featured,
  72. pagination: state => state.blog.pagination
  73. })
  74. },
  75. async fetch({store}) {
  76. const filter = {}
  77. filter.pageNum = 1
  78. filter.pageSize = 2
  79. await store.dispatch('blog/fetchBlogs', filter)
  80. await store.dispatch('blog/fetchFeaturedBlogs', {'filter[featured]': true})
  81. },
  82. methods: {
  83. handleClick() {
  84. alert('Page Clicked!')
  85. }
  86. }
  87. }
  88. </script>
  89. <style scoped>
  90. .post-content {
  91. font-style: italic;
  92. }
  93. .pagination-content {
  94. display: flex;
  95. justify-content: flex-end;
  96. }
  97. .clickable {
  98. cursor: pointer;
  99. }
  100. #root {
  101. flex: 1 0 auto;
  102. }
  103. *:focus {
  104. outline: none;
  105. }
  106. a {
  107. transition: all .35s;
  108. color: #000;
  109. }
  110. .button:focus {
  111. border-color: #d74436;
  112. box-shadow: 0 0 0 0;
  113. }
  114. .input, .textarea, .input[type] {
  115. font-size: 1.1rem;
  116. }
  117. .input:focus, .textarea:focus, .input[type]:focus {
  118. border: 2px solid #d74436;
  119. }
  120. /* this is used when inline-styled content
  121. overlaps text backgrounds in a really ugly way */
  122. .buffer {
  123. padding-bottom: 1.1rem;
  124. }
  125. /* navigation */
  126. .nav {
  127. background-color: #0d0c0d;
  128. }
  129. .nav-left {
  130. padding-left: 2rem;
  131. }
  132. .nav-right, .nav-center {
  133. padding-right: 2rem;
  134. }
  135. a.nav-item.is-tab {
  136. font-weight: 700;
  137. font-size: 13px;
  138. text-transform: uppercase;
  139. color: #fff;
  140. padding: 0.4rem;
  141. }
  142. a.nav-item:hover {
  143. color: #d74436;
  144. }
  145. a.nav-item.is-tab:hover {
  146. border-bottom: 4px solid #d74436;
  147. }
  148. /* main content */
  149. .main-content {
  150. padding: 4rem 0 2rem 0;
  151. min-height: 800px
  152. }
  153. .main-content .container {
  154. padding: 0 2rem 2rem 2rem;
  155. }
  156. /* section */
  157. .section {
  158. padding: 0 0 2rem 0;
  159. }
  160. .section-header {
  161. padding-bottom: 3rem;
  162. }
  163. .section-header .title {
  164. text-transform: uppercase;
  165. color: #4a4a4a;
  166. font-size: 1.3rem;
  167. }
  168. .section-header a {
  169. color: #d74436;
  170. font-weight: 700;
  171. }
  172. .section-header a:hover {
  173. color: #e50076;
  174. }
  175. /* sidebar */
  176. .sidebar-header {
  177. border-color: #d74436;
  178. padding-bottom: 1rem;
  179. border-bottom: 4px solid #d74436;
  180. }
  181. .sidebar-header .title, .sidebar-header-single .title {
  182. font-weight: 700;
  183. text-transform: uppercase;
  184. font-size: 1.3rem;
  185. }
  186. .sidebar-list p, .sidebar-list-single p {
  187. font-size: 1.1rem;
  188. font-weight: 300;
  189. padding-bottom: 0.8rem;
  190. }
  191. .sidebar-list a {
  192. color: #4a4a4a;
  193. }
  194. .sidebar-list, .post-content, .sidebar-list-single {
  195. padding-top: 1.4rem;
  196. }
  197. .sidebar-list-nav {
  198. padding-top: 1rem;
  199. }
  200. .sidebar-list-nav .is-tab {
  201. padding-right: 1rem;
  202. }
  203. .sidebar-footer-single {
  204. padding-top: 2rem;
  205. }
  206. .sidebar-footer-single a {
  207. color: #000;
  208. font-weight: 700;
  209. text-transform: uppercase;
  210. font-size: 1.1rem;
  211. border-right: 4px solid #d74436;
  212. padding-right: 1rem;
  213. }
  214. .sidebar-footer-single a:hover {
  215. color: #363636;
  216. }
  217. /* post */
  218. .post-header, .sidebar-header-single {
  219. border-color: #d74436;
  220. padding-left: 1rem;
  221. border-left: 4px solid #d74436;
  222. }
  223. .post-header .title {
  224. font-weight: 700;
  225. font-size: 1.8rem;
  226. color: rgba(0,0,0,.84)!important;
  227. fill: rgba(0,0,0,.84)!important;
  228. }
  229. .post-header .subtitle, .sidebar-header-single .subtitle {
  230. font-size: 1.1rem;
  231. }
  232. .post-content p, .post-single-content p {
  233. margin-bottom: 0.8rem;
  234. }
  235. .post-content, .post-single-content {
  236. font-size: 1.1rem;
  237. font-weight: 300;
  238. }
  239. /* override */
  240. .post-single-content form p:nth-child(even) {
  241. border-right: 0;
  242. }
  243. .post-single-content form label {
  244. text-transform: uppercase;
  245. color: #4a4a4a;
  246. padding-bottom: 0.2rem;
  247. }
  248. .post-single-content form .input[type] {
  249. padding-top: 0.2rem;
  250. }
  251. .post-single-content p:nth-child(even) {
  252. border-right: 4px solid #d74436;
  253. padding-right: 1rem;
  254. }
  255. .post-content a {
  256. color: #d74436;
  257. }
  258. .card-content-form form {
  259. padding-top: 1.5rem;
  260. }
  261. .post-footer {
  262. padding: 1.5rem 0 0 0;
  263. }
  264. /* pagination */
  265. .pagination-content {
  266. border-right: 4px solid #d74436;
  267. padding-right: 1rem;
  268. }
  269. .pagination-link.is-current {
  270. background-color: #d74436;
  271. border-color: #d74436;
  272. }
  273. </style>