Skip to content

Commit

Permalink
docs: update doc for new nav logic
Browse files Browse the repository at this point in the history
  • Loading branch information
roadlittledawn committed Aug 19, 2021
1 parent 21d3c8f commit 9b0daed
Showing 1 changed file with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,32 @@ When the user goes to a page, we determine which section of the site they are on

## Add a new top-level nav

To add a brand-new top-level nav, you need to create the necessary `.yml` file and related directories.
To add a brand-new top-level nav, you need to create the necessary `.yml` file and related directories.

1. Add the new directory, sub-directories, and docs to `src/content`.
2. Copy an existing file from the `src/nav` directory or create a new `.yml` nav file from scratch.
1. Add the new directory, sub-directories, and docs to `src/content`.
2. Copy an existing file from the `src/nav` directory or create a new `.yml` nav file from scratch.
3. Customize the new nav file with the list of docs and directories you added.
<Callout variant="tip">
You should have at least one level of nesting inside your new directory. Otherwise, doc titles in the auto-generated nav pages will render as H2 headings. For example, `src/content/level-one/level-two/doc` will work, while `src/content/level-one/doc` will produce strange formatting.
</Callout>
You should have at least one level of nesting inside your new directory.
Otherwise, doc titles in the auto-generated nav pages will render as H2
headings. For example, `src/content/level-one/level-two/doc` will work,
while `src/content/level-one/doc` will produce strange formatting.
</Callout>{' '}
4. Test your build locally to ensure all the menus are working as expected.

If you don't want your new nav to appear on the main landing page, add `rootNav: false` to your `.yml` file. (For an example of this, see `src/nav/style-guide.yml`.)

## Use nav `YAML` to generate auto index content
## Use nav `YAML` to populate page menus

On build we automatically generate an index page for each sub-directory in `src/content` that does not already have an `index.mdx` file and that has at least one `.mdx` or `.md` file in it. When creating the page we look through each nav `YAML` file for a reference to the path to know which nav data to use for the left nav and the auto index page content.
On build we automatically generate a page for each `.mdx` file and an index page for each sub-directory in `src/content` that does not already have an `index.mdx` file and that has at least one `.mdx` or `.md` file in it. When creating the page we look through each nav `YAML` file for a reference to the path to know which nav data to use for the left nav and the auto index page content.

If an index page path is in more than one nav `YAML` file, we use the nav that matches its top level path with the beginning of index page path.
If a page path is in more than one nav `YAML` file, we use the nav that matches its top level path with the beginning of the given page's path.

### Nav requirements for auto index pages
### Nav requirements

In order to populate the auto index page with nav `YAML` data, you must add the index page path somewhere in the most relevant nav `YAML` file. This helps the auto index page plugin determine which nav to attach to the index page, but also helps the `<IndexContents />` component know which section to display on the index page itself.
In order to attach nav `YAML` data to a page, you must add the page path somewhere in the most relevant nav `YAML` file. This helps the local nav plugin determine which nav to attach to a given page. It also helps the `<IndexContents />` component know which section to display on auto index pages.

Each nav item must reference a directory path in `src/content` that contains at least one `.md` or `.mdx` file (otherwise the auto index plugin does not create a page for it).
When adding auto index page links to nav `YAML` files, be aware that auto index pages are only created for file directories in `src/content` that contain at least one `.mdx` or `.md` file.

<Callout variant="tip" title="Example">
If this auto index page is used in `full-stack-observability.yml` and `integrations.yml`, we will attach the `integrations.yml` nav to it because:
Expand All @@ -134,3 +137,23 @@ matches this auto index page path:
```

</Callout>

If a page's path does not match any of the top-level paths in the nav `YAML` files it's referenced in (like the above example), the local nav plugin defaults to the first nav `YAML` file it sees. The order is a alphabetical sort of the top-level `title` fields.

For example, if we have an .mdx file with this path that's included in two nav `YAML` files:

```
<mark>/docs/do-all-the-things</mark>/how-to-monitor-everything
```

We can't determine a "true nav" so the plugin would default to attaching the `full-stack-observability.yml` data to the page, because its `title` value is first alphabetically.

```yaml fileName=src/nav/integrations.yml
<mark>title: Integrations</mark>
path: /docs/integrations
```

```yaml fileName=src/nav/full-stack-observability.yml
<mark>title: Full Stack Observability</mark>
path: /docs/full-stack-observability
```

0 comments on commit 9b0daed

Please sign in to comment.