Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

add watcher on URL param change for category page #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/category.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ export default {
}

},
watch: {
'$route' (to, from) {
const vm = this
console.log('Category param has changed')
if (vm.$route.params.name) {
vm.getCatId(vm.$route.params.name)
}
}
},
data() {

return {
Expand Down
13 changes: 12 additions & 1 deletion src/components/theme-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<ul>
<li v-for="item in menus" v-if="item.type != 'custom'">
<router-link :to="{ name: 'page', params: { name: getUrlName( item.url ) }}"> {{ item.title }} </router-link>
<router-link :to="{ name: getRouteType(item.object), params: { name: getUrlName( item.url ) }}"> {{ item.title }} </router-link>
</li>

</ul>
Expand Down Expand Up @@ -75,6 +75,17 @@ export default {
const array = url.split( '/' );
return array[ array.length - 2 ];
},
getRouteType: function( object ) {
let type = 'page'
if (object === 'category') {
type = 'cat'
} else if (object === 'post') {
type = 'post'
} else if (object === 'tag') {
type = 'tag'
}
return type
},
toggleMenu: function() {
//console.log("Clicked" + this.isActive);
this.isActive = ! this.isActive;
Expand Down