bshiluk / vue-wordpress

Use Vue.js and the WP REST API to build WordPress themes as SPAs with dynamic routing, HMR for development, SEO enabled, and SSR capable. Demo:
http://vue-wordpress-demo.bshiluk.com
491 stars 112 forks source link

Page routes load Single.vue #12

Closed pedrofmiguel closed 4 years ago

pedrofmiguel commented 4 years ago

I'm trying to open open single pages and instead of rendering the component Page.vue it renders the Single.vue component giving me this error

image

I thought this is was my issue and was worried that the vue-router could not distinguish the difference between a post and a page, because the URL was basically the same (which was a bad thought on my part). I used the url http://vue-wordpress-demo.bshiluk.com/wp-json/wp/v2/pages and saw that you were in fact navigating between POSTS and Pages with no problems.

I don't know what else to do , i even cloned the repository again to try to reproduce the errors, and without changing any code the error ocurred again.

Sorry to bother , but i could use the help.

The only diferrence between my code and yours right now, is that i use dynamic routing

routes.js

import { loaderPage } from '@helpers/loaderComponents';

and for example

 {
    path: '/404',
    component: loaderPage('NotFound'),
    name: '404'
  },

loaderComponent.js

export const loaderComponent = (path) => () => import(/* webpackChunkName: '[request]' */ `@components/${path}`).then(m => m.default || m);
export const loaderPage = (path) => () => import(/* webpackChunkName: '[request]' */ `@pages/${path}`).then(m => m.default || m);

I can navigate to posts, author page and categories pages with no problem, but as soon as i enter a page it does not load

pedrofmiguel commented 4 years ago

My problem was solved by changing the type of linked that was used by the post in the backoffice of my wp website

From /slug

To month/slug

Still would be cool if i could use the url to the post with just the slug!

Sorry to bother!!