vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.17k stars 923 forks source link

[Bug report] Cannot override layouts for default theme #166

Closed digisomni closed 3 years ago

digisomni commented 3 years ago

Bug report

Description

Following any and all official documentation from vuepress or vuepress-next, I am unable to override the 404 page.

Steps to reproduce

Try to override the 404 page by creating the file .vuepress/theme/index.js and filling it in with...

const { path } = require('@vuepress/utils')

module.exports = {
  name: 'vuepress-theme-local',
  extends: '@vuepress/theme-default',
  layouts: {
    404: path.resolve(__dirname, 'layouts/404.vue'),
  }
}

Then create a file from there in the layouts folder called 404.vue.

When I do this, the default error page still shows up.

Expected behavior

I expect my new component to show up instead of the default error page.

Environment info

digisomni commented 3 years ago

Found the problem, none of the documentation that I found outlines that this must also be done first so this line should be referenced somewhere, probably in the cookbook (https://vuepress2.netlify.app/advanced/cookbook/extending-a-theme.html#extend-default-theme) next to where it's telling us how to do this in the first place:

theme: path.resolve(__dirname, 'theme'),

Is a required line to get it to find your theme.

meteorlxy commented 3 years ago

We put the cookbook in the "Advanced" part, assuming that you have read the basic guide

https://vuepress2.netlify.app/guide/theme.html