EvanAgee / vuejs-wordpress-theme-starter

A WordPress theme with the guts ripped out and replaced with Vue.
https://vuewp.com/
1.6k stars 281 forks source link

common vue.js template #14

Closed jajouka79 closed 6 years ago

jajouka79 commented 6 years ago

i understand that in router/index.js you can link a wp page by id to a vue component, i have 2 routes set up like this -

  {
      path: '/',
      name: 'Home',
      component: Home,
      // props: { pageContentID: 383 }
  },
  {
      path: '/about',
      name: 'About',
      component: About,
      props: { pageContentID: 16 }
  }

and my-url.local/about works fine

however when a wordpress administrator is adding new pages there is no fallback templates, in regular wordpress those would be page.php, post.php etc.

how can I add these fallback view templates or are they already there and I haven't found them yet?

EvanAgee commented 6 years ago

Hi @jajouka79, welcome to the project! If you want to create a fallback template you're probably going to want to setup a route for something like post/:slug which will allow you to create a generic Vue template for displaying your posts. I would ignore the example I have in the routes, I'll update it soon.

jajouka79 commented 6 years ago

hi. ive just got back onto this project and checked out your suggestion, i can't get it to work, here's the routes in index.js:

 routes: [
      {
          path: '/',
          name: 'Home',
          component: Home
      },
      {
          path: '/about',
          name: 'About',
          component: About,
          props: { pageContentID: 16 }
      },
      {
          path: 'post/:slug',
          name: 'Post',
          component: Post
      }
  ],
jajouka79 commented 6 years ago

btw i have a file Post.vue included in index.js:

import Post from '../components/Post'

app.js is compiled correctly