index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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="5"
  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. })
  73. },
  74. async fetch({store}) {
  75. await store.dispatch('blog/fetchBlogs')
  76. await store.dispatch('blog/fetchFeaturedBlogs', {'filter[featured]': true})
  77. },
  78. methods: {
  79. handleClick() {
  80. alert('Page Clicked!')
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .post-content {
  87. font-style: italic;
  88. }
  89. .pagination-content {
  90. display: flex;
  91. justify-content: flex-end;
  92. }
  93. .clickable {
  94. cursor: pointer;
  95. }
  96. #root {
  97. flex: 1 0 auto;
  98. }
  99. *:focus {
  100. outline: none;
  101. }
  102. a {
  103. transition: all .35s;
  104. color: #000;
  105. }
  106. .button:focus {
  107. border-color: #d74436;
  108. box-shadow: 0 0 0 0;
  109. }
  110. .input, .textarea, .input[type] {
  111. font-size: 1.1rem;
  112. }
  113. .input:focus, .textarea:focus, .input[type]:focus {
  114. border: 2px solid #d74436;
  115. }
  116. /* this is used when inline-styled content
  117. overlaps text backgrounds in a really ugly way */
  118. .buffer {
  119. padding-bottom: 1.1rem;
  120. }
  121. /* navigation */
  122. .nav {
  123. background-color: #0d0c0d;
  124. }
  125. .nav-left {
  126. padding-left: 2rem;
  127. }
  128. .nav-right, .nav-center {
  129. padding-right: 2rem;
  130. }
  131. a.nav-item.is-tab {
  132. font-weight: 700;
  133. font-size: 13px;
  134. text-transform: uppercase;
  135. color: #fff;
  136. padding: 0.4rem;
  137. }
  138. a.nav-item:hover {
  139. color: #d74436;
  140. }
  141. a.nav-item.is-tab:hover {
  142. border-bottom: 4px solid #d74436;
  143. }
  144. /* main content */
  145. .main-content {
  146. padding: 4rem 0 2rem 0;
  147. min-height: 800px
  148. }
  149. .main-content .container {
  150. padding: 0 2rem 2rem 2rem;
  151. }
  152. /* section */
  153. .section {
  154. padding: 0 0 2rem 0;
  155. }
  156. .section-header {
  157. padding-bottom: 3rem;
  158. }
  159. .section-header .title {
  160. text-transform: uppercase;
  161. color: #4a4a4a;
  162. font-size: 1.3rem;
  163. }
  164. .section-header a {
  165. color: #d74436;
  166. font-weight: 700;
  167. }
  168. .section-header a:hover {
  169. color: #e50076;
  170. }
  171. /* sidebar */
  172. .sidebar-header {
  173. border-color: #d74436;
  174. padding-bottom: 1rem;
  175. border-bottom: 4px solid #d74436;
  176. }
  177. .sidebar-header .title, .sidebar-header-single .title {
  178. font-weight: 700;
  179. text-transform: uppercase;
  180. font-size: 1.3rem;
  181. }
  182. .sidebar-list p, .sidebar-list-single p {
  183. font-size: 1.1rem;
  184. font-weight: 300;
  185. padding-bottom: 0.8rem;
  186. }
  187. .sidebar-list a {
  188. color: #4a4a4a;
  189. }
  190. .sidebar-list, .post-content, .sidebar-list-single {
  191. padding-top: 1.4rem;
  192. }
  193. .sidebar-list-nav {
  194. padding-top: 1rem;
  195. }
  196. .sidebar-list-nav .is-tab {
  197. padding-right: 1rem;
  198. }
  199. .sidebar-footer-single {
  200. padding-top: 2rem;
  201. }
  202. .sidebar-footer-single a {
  203. color: #000;
  204. font-weight: 700;
  205. text-transform: uppercase;
  206. font-size: 1.1rem;
  207. border-right: 4px solid #d74436;
  208. padding-right: 1rem;
  209. }
  210. .sidebar-footer-single a:hover {
  211. color: #363636;
  212. }
  213. /* post */
  214. .post-header, .sidebar-header-single {
  215. border-color: #d74436;
  216. padding-left: 1rem;
  217. border-left: 4px solid #d74436;
  218. }
  219. .post-header .title {
  220. font-weight: 700;
  221. font-size: 1.8rem;
  222. color: rgba(0,0,0,.84)!important;
  223. fill: rgba(0,0,0,.84)!important;
  224. }
  225. .post-header .subtitle, .sidebar-header-single .subtitle {
  226. font-size: 1.1rem;
  227. }
  228. .post-content p, .post-single-content p {
  229. margin-bottom: 0.8rem;
  230. }
  231. .post-content, .post-single-content {
  232. font-size: 1.1rem;
  233. font-weight: 300;
  234. }
  235. /* override */
  236. .post-single-content form p:nth-child(even) {
  237. border-right: 0;
  238. }
  239. .post-single-content form label {
  240. text-transform: uppercase;
  241. color: #4a4a4a;
  242. padding-bottom: 0.2rem;
  243. }
  244. .post-single-content form .input[type] {
  245. padding-top: 0.2rem;
  246. }
  247. .post-single-content p:nth-child(even) {
  248. border-right: 4px solid #d74436;
  249. padding-right: 1rem;
  250. }
  251. .post-content a {
  252. color: #d74436;
  253. }
  254. .card-content-form form {
  255. padding-top: 1.5rem;
  256. }
  257. .post-footer {
  258. padding: 1.5rem 0 0 0;
  259. }
  260. /* pagination */
  261. .pagination-content {
  262. border-right: 4px solid #d74436;
  263. padding-right: 1rem;
  264. }
  265. .pagination-link.is-current {
  266. background-color: #d74436;
  267. border-color: #d74436;
  268. }
  269. </style>