xyd 0.1.0-beta - Coming Soon

Core concepts
/
Navigation

Navigation

Learn how to navigate your docs

Navigation is one of the core concepts in xyd to understand as it determines how your documentation pages are organized, navigated, and accessed by users. It provides flexible ways to structure your content.

Overview

You can customize the navigation by adding a routes in docs.json file to your project.

The navigation property controls the hierarchy of your documentation. It's grouped into multiple properties:

  • sidebar - Main navigation, usually displayed on the left side where all pages are rendered.
  • tabs - Navigate through tabs, the most in header area.
  • sidebarDropdown - Navigate through sidebar dropdown.
  • anchors - Fixed navigation, helpful for displaying a static navigation/links.
  • segments - Smaller navigational structures based on specific route.

Dividing a navigation into multiple properties helps you to organize your documentation better.

asset

The simples way to define sidebar is declaring a pages within it:

Note you do not need to append .md/.mdx or / at beginning to the file paths.

Groups

If you need more advanced structures, define sidebar as object:

Nested Groups

You can also define nested groups:

Group PageComing Soon

If you want to have a clickable group as a page, define page instead of group:

Routing

You can also do more advanced routing in the sidebar, like matching based on the specific route:

Order

Thanks to order you are able to set a custom order of docs groups. It's the most useful with auto-generatated docs - for OpenAPI/GraphQL integration for example. There are a few options how to change an order:

Tabs

Tabs

Navigation Item structure displayed in tabs-like style:

Tabs API Reference
Check the full Tabs API Reference
    array of NavigationItem
    Core interface for navigation items
      title
      string
      The navigation item title
      description
      string
      The navigation item description
      page
      string
      The navigation page, if set it redirects to the page + matches based on routing
      href
      string
      The navigation href, if set it redirects but does not match based on routing
      icon
      React.ReactNode
      The navigation item icon

Sidebar Dropdown

Navigation Item structure displayed in dropdown-like style inside sidebar:

Sidebar Dropdown API Reference
Check the full Sidebar Dropdown API Reference
    array of NavigationItem
    Core interface for navigation items
      title
      string
      The navigation item title
      description
      string
      The navigation item description
      page
      string
      The navigation page, if set it redirects to the page + matches based on routing
      href
      string
      The navigation href, if set it redirects but does not match based on routing
      icon
      React.ReactNode
      The navigation item icon

Anchors

asset

Anchors provide a way to add fixed navigation elements. They're useful for displaying important external links or resources.

Anchors API Reference
Check the full Anchors API Reference
    header
    array of AnchorHeader
    Header anchors
      NavigationItem
      NavigationItem
      Core interface for navigation items
        title
        string
        The navigation item title
        description
        string
        The navigation item description
        page
        string
        The navigation page, if set it redirects to the page + matches based on routing
        href
        string
        The navigation href, if set it redirects but does not match based on routing
        icon
        React.ReactNode
        The navigation item icon
      NavigationItemButton
      NavigationItemButton
        NavigationItem
        NavigationItem
        Core interface for navigation items
          title
          string
          The navigation item title
          description
          string
          The navigation item description
          page
          string
          The navigation page, if set it redirects to the page + matches based on routing
          href
          string
          The navigation href, if set it redirects but does not match based on routing
          icon
          React.ReactNode
          The navigation item icon
        NavigationItem & { button: "primary"
        NavigationItem & { button: "primary"
        "secondary"; }
        "secondary"; }
      NavigationItemSocial
      NavigationItemSocial
        NavigationItem
        NavigationItem
        Core interface for navigation items
          title
          string
          The navigation item title
          description
          string
          The navigation item description
          page
          string
          The navigation page, if set it redirects to the page + matches based on routing
          href
          string
          The navigation href, if set it redirects but does not match based on routing
          icon
          React.ReactNode
          The navigation item icon
        NavigationItem & { social: Social; }
        NavigationItem & { social: Social; }
    sidebar
    { top?: NavigationItem[]; bottom?: NavigationItem[]; }
    Sidebar anchors
      top
      array of NavigationItem
      bottom
      array of NavigationItem

SegmentsExperimental

asset

Segments allows you to create smaller navigational structures based on specific route. Thanks to that you can create for example a subheader that will shown only on specific route:

Segments API Reference
Check the full Segment API Reference
    route
    string
    Required
    Route for this segment
    title
    string
    Title of this segment
    appearance
    "sidebarDropdown"
    Appearance of this segment. If 'sidebarDropdown' then show this segment as a dropdown in the sidebar if match.
    pages
    array of NavigationItem
    Required
    Core interface for navigation items
      title
      string
      The navigation item title
      description
      string
      The navigation item description
      page
      string
      The navigation page, if set it redirects to the page + matches based on routing
      href
      string
      The navigation href, if set it redirects but does not match based on routing
      icon
      React.ReactNode
      The navigation item icon

File-Convention RoutingComing Soon

File-convention routing is powerful because you don't need any configuration but also has some limitations.
If you need more control over the routing, you need to use the settings based routing instead.

Using file-convention routing means the generated HTML pages are mapped from the directory structure of the source Markdown files.

For example, given the following directory structure:

The generated HTML pages will be:

index.md

If you crate an index.md file at root of your documentation project, xyd will serve that content as index page.

Built with

Show your support! Star us on GitHub ⭐️