Navigation
Organize the sidebar and navbar.
The sidebar lists the pages in content/, with a group for each folder. The navbar holds the site title and links.
Sidebar
The sidebar shows each page under the title in its frontmatter, and each folder as a group that opens on click. In a folder, index.md comes first, then the pages, then the subfolders, each in alphabetical order:
vuesho dev updates the sidebar as you add, move or rename files, and each page's URL follows its file path.
Folders
A meta.json in a folder sets the folder's title, its icon and the order of its pages:
{
"title": "Guide",
"defaultOpen": true,
"pages": ["install", "configure", "..."]
}Prop
Type
The folder's sidebar item links to its index.md, and shows the title from meta.json, or the index page's title when meta.json has none. When pages lists index, the page has its own item instead.
A meta file can also be YAML, or a meta.ts module that runs when the site builds, for example to set data per param value:
{
"title": "Guide",
"pages": ["install", "configure", "..."]
}Page Order
pages lists the pages and subfolders in order, by file name without .md. The list can also hold separators and links:
pages:
# The page `index.md`. The root has no folder item that opens it, so list it here
- index
# The page `guide.md`, or the folder `guide/`.
- guide
# A separator titled "Reference". Write `---[Book]Reference---` to add an icon
- ---Reference---
# The pages of the folder `reference/`, in place of the folder.
- ...reference
# A link. Write `[Star][GitHub](https://...)` to add an icon
- "[GitHub](https://github.com/acme/docs)"
# An external link, with an external-link icon. It opens in a new tab
- "external:[Discord](https://discord.gg/acme)"
# The other pages, then folders, in alphabetical order. Use `z...a` for reverse order
- "..."
# Leaves `changelog` out of `...`.
- "!changelog"Hidden Pages
A page missing from pages is hidden from the sidebar, but keeps its URL. With "..." in the list, put ! before a name to hide that page:
{
"pages": ["index", "guide", "...", "!changelog"]
}Drafts
A page with draft: true in its frontmatter shows in vuesho dev, but the build leaves out the page, its sidebar item and its search entry:
---
title: Next Release
draft: true
---A link to a draft fails the build's link validation.
Root Folders
A folder with "root": true is a separate section. The sidebar shows only the current section's pages, and a switch at the top of the sidebar opens the other sections:
{
"title": "Guide",
"description": "Learn the basics",
"root": true
}A page outside every root folder, like content/index.md, shows the whole sidebar.
Versions
Set root to a string, like "version", to put the folders with the same string in a separate switch, such as a version switch:
{
"title": "v1",
"root": "version"
}On /v1/guide, picking v2 opens /v2/guide. When /v2/guide doesn't exist, it opens v2's first page. A version folder can also hold sections with "root": true.
Switches in Layouts
Only the docs and notebook layouts show a switch for each string of root. The other layouts show only the folders with "root": true.
Icons
A page or a folder shows an icon beside its name in the sidebar. Import the icon from an icon library, like Lucide, and set it as icon in code, so the site loads only the icons it uses:
import { BookOpen } from "@lucide/vue";
export default {
title: "Guide",
icon: BookOpen,
};Any Vue component works, from any library.
Icon Names
icon in a page's frontmatter or in a meta.json can also be the name of a Lucide icon:
---
title: Getting Started
icon: Rocket
---lucideIconsPlugin() renders the names as Lucide icons. Install @lucide/vue and add the plugin:
npm i @lucide/vueimport { createSite, recommendedPreset } from "vuesho/config";
import { defineDocs } from "vuesho/content";
import { lucideIconsPlugin } from "vuesho/lucide-icons";
const docs = defineDocs();
export default createSite(docs.toSource()).plugins(
recommendedPreset(),
// `defaultIcon` is the icon of a page or a folder without one.
lucideIconsPlugin({ defaultIcon: "File" }),
);A name that Lucide doesn't have shows no icon, and vuesho dev logs a warning. The server keeps every Lucide icon to look the names up, so a site that doesn't use names can leave the plugin out.
Custom Names
Without the plugin, set icon in createSite() to a function that returns the icon for a name: a component, or text like an emoji:
import { BookOpen, Rocket } from "@lucide/vue";
import { createSite, recommendedPreset } from "vuesho/config";
import { defineDocs } from "vuesho/content";
const docs = defineDocs();
const icons = { BookOpen, Rocket };
export default createSite(docs.toSource(), {
// A name of `icons` is its component, and any other name is shown as text.
icon: (name) => (name === undefined ? undefined : (icons[name as keyof typeof icons] ?? name)),
}).plugins(recommendedPreset());---
title: Introduction
icon: 🚀
---Status Badges
statusBadgesPlugin() shows a badge next to a page in the sidebar, from the status field in its frontmatter:
---
title: Search
status: new
---Add the Plugin
import { statusBadgesPlugin } from "vuesho/status-badges";
createSite(docs.toSource()).plugins(
recommendedPreset(),
statusBadgesPlugin(),
);Style the Badges
A badge is a <span data-status="..."> without styles. Style it in your stylesheet:
@import "vuesho/style/neutral.css";
[data-status] {
margin-inline-start: auto;
border-radius: 9999px;
padding: 0 0.5rem;
font-size: 0.75rem;
background-color: var(--color-fd-primary);
color: var(--color-fd-primary-foreground);
}
[data-status="deprecated"] {
background-color: var(--color-fd-muted);
color: var(--color-fd-muted-foreground);
}To render a custom badge for each status, as text or a VNode, use renderBadge:
import { h } from "vue";
import { statusBadgesPlugin } from "vuesho/status-badges";
createSite(docs.toSource()).plugins(
recommendedPreset(),
statusBadgesPlugin({
renderBadge: (status) =>
h("span", { "data-status": status }, status === "new" ? "New" : status),
}),
);Navbar
ui.layoutProps in the config sets the navbar's title and links, in every layout:
createSite(docs.toSource()).config({
ui: {
layoutProps: {
nav: { title: "Acme" },
links: [
{ text: "Guide", url: "/guide", active: "nested-url" },
{ text: "Discord", url: "https://discord.gg/acme" },
{
type: "menu",
text: "Community",
items: [
{ text: "Forum", url: "https://forum.acme.dev", description: "Ask a question." },
{ text: "Showcase", url: "https://acme.dev/showcase" },
],
},
],
},
},
});Prop
Type
ui.layoutProps reaches the browser as JSON, so a component with state, like a button that opens a dialog, goes in the theme's layoutProps instead. A prop for one layout goes in a layout wrapper.
Links
type sets how a link renders. A link to another site opens in a new tab, and the build validates links to your own pages:
import { MessageCircle } from "@lucide/vue";
createSite(docs.toSource()).config({
ui: {
layoutProps: {
links: [
// A text link, the default, with an optional `icon` and `description`.
{ text: "Blog", url: "/blog" },
// An icon, whose `label` is read by screen readers.
{
type: "icon",
text: "Discord",
label: "Discord",
icon: MessageCircle,
url: "https://discord.gg/acme",
},
// A button.
{ type: "button", text: "Get Started", url: "/" },
// A menu of the links in `items`.
{ type: "menu", text: "More", items: [{ text: "Changelog", url: "/changelog" }] },
],
},
},
});A text link has these fields, which the other types share:
Prop
Type
Logo
site.logo shows an image before the site name in the navbar:
createSite(docs.toSource()).config({
// `public/logo.svg`, with the base path added
site: { name: "Acme", logo: "/logo.svg" },
});For a logo per language, or other markup, set nav.title:
import { h } from "vue";
createSite(docs.toSource()).config({
ui: {
// As a function, receives `{ lang }`. `nav.title` takes text, a component or a VNode.
layoutProps({ lang }) {
const src = this.addBasePath(lang === "cn" ? "/logo-cn.svg" : "/logo.svg");
return { nav: { title: h("img", { src, alt: "Acme", height: 24 }) } };
},
},
});Repository
site.git adds a link to the repository in the navbar, and an Open in GitHub link to each page's view options:
createSite(docs.toSource()).config({
site: {
// The site is in `apps/docs` of github.com/acme/docs, on the branch `dev`.
git: { user: "acme", repo: "docs", branch: "dev", dir: "apps/docs" },
},
});Prop
Type