-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is the navigation bar not being retained after I made a custom layout? #1656
Comments
I also just experienced this. The docs on custom page layouts read:
So apparently the component given in I was able to fix this by explicitly wrapping my page layout around <template>
<Layout>
<template slot="page-top">
<!-- My page content here -->
</template>
</Layout>
</template>
<script>
import Layout from "@theme/layouts/Layout.vue";
export default {
components: { Layout },
};
</script> See also Layout.vue. 👍 Maybe this should be documented in the custom layouts docs section? |
Thank you for your reply. I solved my problem by import Navbar directly into my custom layout. But I quite agree with you, which should be made clear in the document. The inconsistency between the actual situation and the description of the document will bring a lot of trouble. |
Another strategy, for customizing pages that only need small css changes, is to use frontmatter to override the style of the Content part (set pageClass to a class style), and add that class style into .vuepress/styles/index.styl. This allows you to target only the markdown part of the page (what is transferred into the Content slot), without impact on the rest of the layout (navbar, sidebar). |
Since this still open I'll add my issue here. I'm currently using Vuepress 1.x <template>
<Navbar />
<component :is="layout" />
<Footer />
</template>
<script>
import BaseLayout from "@theme/layouts/BaseLayout";
//require('../styles/main.scss');
require("prismjs/themes/prism-tomorrow.css");
export default {
name: "Layout",
components: {
BaseLayout
},
computed: {
layout() {
if (this.$page.path) {
return this.$frontmatter.layout || "BaseLayout";
}
return "NotFound";
}
}
};
</script> Now, I understand how this could happen but still, I find it a weird behavior and the Doc is not helping at all in its current state. Any suggestion? |
Bug report
Steps to reproduce
What is expected?
What is actually happening?
Other relevant information
My VuePress version is lower and euqal than
1.0.0-alpha.47
:My VuePress version is higher than
1.0.0-alpha.47
, the following is the output ofnpx vuepress info
in my VuePress project:The text was updated successfully, but these errors were encountered: