I created my own custom component and placed it in the appropriate folder. I then called said component in my markdown file frontmatter using the syntax below:
title: Marketing Dashboards
layout: DashboardGallery
---
The component displays just fine but the navbar is gone which is contrary to what is indicated in the documentation (https://v1.vuepress.vuejs.org/theme/default-theme-config.html#custom-layout-for-specific-pages)
Am I missing something?
[email protected] is the version I am on
I should be seeing the navbar
It's no visible with the custom layout
I think the problem lies on line 45-48 of the [routes.js](https://github.com/vuejs/vuepress/blob/e5d8ed4655b42e975a1d72286bc859257b3d2eb9/packages/%40vuepress/core/lib/node/internal-plugins/routes.js) file
let code = `
{
name: ${JSON.stringify(componentName)},
path: ${JSON.stringify(pagePath)},
component: GlobalLayout,
beforeEnter: (to, from, next) => {
ensureAsyncComponentsLoaded(${JSON.stringify(layout || 'Layout')}, ${JSON.stringify(componentName)}).then(next)
},${_meta ? `\n meta: ${JSON.stringify(_meta)}` : ''}
}`
the default Layout from the Theme cannot be used in conjunction with the layout frontmatter variable as it was in version 0.x. In order to have the themes default navbar/sidebar I would have to either redefine it in my custom layout or write a globalLayout which in this case would duplicate the navbar of the default theme.
Perhaps we could add another variable in the frontmatter indicating if the globalLayout or theme layout is to be used or both??
Thoughts?
For example:
GlobalLayout so that every layout will have a navbar.And in conclusion, it is an expected behavior.
@Shigma Sorry to reply on a closed topic but my question is exactly the same. I'm using the default theme but I do not have the theme folder.
The documentation is a bit confusing when it says "while only keeping the navbar", because actually it's not showing the navbar:
By default the content of each *.md file is rendered in a
<div class="page">container, along with the sidebar, auto-generated edit links and prev/next links. If you wish to use a completely custom component in place of the page (while only keeping the navbar), you can again specify the component to use using YAML front matter.
So, after a simple install, could you please clarify how we can have the default-theme folders in the project?
Thanks
@Shigma Sorry to reply on a closed topic but my question is exactly the same. I'm using the default theme but I do not have the theme folder.
The documentation is a bit confusing when it says "while only keeping the navbar", because actually it's not showing the navbar:
By default the content of each *.md file is rendered in a
<div class="page">container, along with the sidebar, auto-generated edit links and prev/next links. If you wish to use a completely custom component in place of the page (while only keeping the navbar), you can again specify the component to use using YAML front matter.So, after a simple install, could you please clarify how we can have the default-theme folders in the project?
Thanks
It's working creating the home.vue inside components folder and importing the component on readme.md file (home page) like this:
home: true
---
<home/>
I'm just not if it's the correct approach.
Cheers
@Shigma I think the previous approach made more sense in v.0x, now if I want a custom layout with the default theme I have to manually add the navbar and the sidebar so that it is consistent across the site. It made way more sense before to just have to pass a frontmatter variable that controlled having a navbar and sidebar...just my 2cents. The doc should also be updated to reflect the change that you stated if that's the new format.
Otherwise, really love vuepress so thanks for all the work.
@Shigma could you provide clarification between Layout.vue and GlobalLayout.vue, it seems a bit redundant to have both of these and not just have the Layout.vue acting in a Global fashion as it was in v0.x?
I am simply trying to understand the use cases in which you would need to have the two separated?
Would also love to hear other peoples opinions on the subject...
I second better documentation and definitely more examples. At this moment I am still not entirely sure what is the layout: frontmatter actually doing, where that vue file should be placed, and how to chain it to the inherited components. Please explain differently for (1) someone writing a complete theme for export as an NPM and (2) someone wanting just to override a few special pages with local override templates, e.g. a carousel or a custom 404 page, and (3) someone who wants to write part of the site in vue single page format and how to define the frontmatter in vue instead of md. Browsing tutorials around the web is totally confusing particularly because of the 0.x to 1.x changes.
Most helpful comment
I second better documentation and definitely more examples. At this moment I am still not entirely sure what is the layout: frontmatter actually doing, where that vue file should be placed, and how to chain it to the inherited components. Please explain differently for (1) someone writing a complete theme for export as an NPM and (2) someone wanting just to override a few special pages with local override templates, e.g. a carousel or a custom 404 page, and (3) someone who wants to write part of the site in vue single page format and how to define the frontmatter in vue instead of md. Browsing tutorials around the web is totally confusing particularly because of the 0.x to 1.x changes.