Procházet zdrojové kódy

:recycle: moving from query to route prop

tags/0.9.0
j před 5 roky
rodič
revize
2370ec0ffd
2 změnil soubory, kde provedl 7 přidání a 5 odebrání
  1. 2
    4
      vue-theme/src/pages/list.vue
  2. 5
    1
      vue-theme/src/router/routes.js

+ 2
- 4
vue-theme/src/pages/list.vue Zobrazit soubor

6
             span(v-if="sortBy")
6
             span(v-if="sortBy")
7
                 h1  sorted by {{ sortBy.replace('-', ' ') }}
7
                 h1  sorted by {{ sortBy.replace('-', ' ') }}
8
 
8
 
9
-        .posts(:class="{ 'is-grid': isGrid }")
9
+        .posts(:class="{ 'is-grid': grid }")
10
             section(v-for="post in posts" :key="post.slug").shadow.post
10
             section(v-for="post in posts" :key="post.slug").shadow.post
11
                 router-link(:to="`/${type}/${post.slug}`")
11
                 router-link(:to="`/${type}/${post.slug}`")
12
                     h4 {{ post.title }} 
12
                     h4 {{ post.title }} 
34
     components: { sidebar },
34
     components: { sidebar },
35
     props: {
35
     props: {
36
         sidebar: { type: Boolean },
36
         sidebar: { type: Boolean },
37
+        grid: { type: Boolean },
37
         sortBy: { type: String }
38
         sortBy: { type: String }
38
     },
39
     },
39
     mixins: [postTypeGetters],
40
     mixins: [postTypeGetters],
40
     computed: {
41
     computed: {
41
-        isGrid() {
42
-            return this.$route.query.grid === 'true'
43
-        },
44
         type() { // Checks for type and fixes Episodes route edge case 
42
         type() { // Checks for type and fixes Episodes route edge case 
45
             return typeFromRoute(this.$route)
43
             return typeFromRoute(this.$route)
46
         },
44
         },

+ 5
- 1
vue-theme/src/router/routes.js Zobrazit soubor

6
     // Home Page
6
     // Home Page
7
     { path: '/', component: indexPage },
7
     { path: '/', component: indexPage },
8
     // List Pages
8
     // List Pages
9
-    { path: '/episodes', component: listPage, props: { sidebar: false } },
9
+    { 
10
+        path: '/episodes',
11
+        component: listPage,
12
+        props: { sidebar: false, grid: true }
13
+    },
10
     { path: '/:type', component: listPage, props: { sidebar: true } },
14
     { path: '/:type', component: listPage, props: { sidebar: true } },
11
     // Sorted List Pages 
15
     // Sorted List Pages 
12
     { path: '/:type/by-alpha', component: listPage, props: { sidebar: true, sortBy: 'by-alpha' } },
16
     { path: '/:type/by-alpha', component: listPage, props: { sidebar: true, sortBy: 'by-alpha' } },

Načítá se…
Zrušit
Uložit