Skip to content

Commit

Permalink
Merge pull request #1540 from hydephp/add-dedicated-navigation-docume…
Browse files Browse the repository at this point in the history
…ntation-page

Add dedicated navigation documentation page
  • Loading branch information
caendesilva authored Feb 9, 2024
2 parents dc81e5f + d003297 commit a4313b2
Show file tree
Hide file tree
Showing 4 changed files with 329 additions and 153 deletions.
16 changes: 8 additions & 8 deletions docs/creating-content/documentation-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,8 @@ and where the data is from as well as where it can be overridden.
The sidebar is automatically generated from the files in the `_docs` directory. You will probably want to change the order
of these items. You can do this in two ways, either in the config or with front matter using the navigation array settings.

### Table of contents

Hyde automatically generates a table of contents for the page and adds it to the sidebar.

The behaviour of this can be changed in the configuration file.
See [the customization page](customization#navigation-menu--sidebar) for more details.
Since this feature shares a lot of similarities and implementation details with the navigation menu,
I recommend you read the [navigation menu documentation](navigation-menu) page as well to learn more about the fundamentals and terminology.

### Sidebar ordering

Expand Down Expand Up @@ -137,7 +133,7 @@ Sidebar grouping allows you to group items in the sidebar into categories. This
The Hyde docs for instance use this.

The feature is enabled automatically when one or more of your documentation pages have the `navigation.group` property set
in the front matter. This will then switch to a slightly more compact sidebar layout with pages sorted into categories.
in the front matter, or when subdirectories are used. This will then switch to a slightly more compact sidebar layout with pages sorted into categories.
Any pages without the group front matter will get put in the "Other" group.

### Sidebar footer customization
Expand Down Expand Up @@ -169,7 +165,9 @@ You can also automatically group your documentation pages by placing source file

For example, putting a Markdown file in `_docs/getting-started/`, is equivalent to adding the same front matter seen above.

>info Note that when the [flattened output paths](#using-flattened-output-paths) setting is enabled (which it is by default), the file will still be compiled to the `_site/docs/` directory like it would be if you didn't use the subdirectories.
>info Note that when the [flattened output paths](#using-flattened-output-paths) setting is enabled (which it is by default), the file will still be compiled to the `_site/docs/` directory like it would be if you didn't use the subdirectories. Note that this means that you can't have two documentation pages with the same filename as they overwrite each other.

>info Tip: When using subdirectory-based dropdowns, you can set their priority using the directory name as the array key.

### Hiding items

Expand Down Expand Up @@ -252,6 +250,8 @@ Please note that this option is not added to the config file by default, as it's

### Table of contents settings

Hyde automatically generates a table of contents for the page and adds it to the sidebar.

In the `config/docs.php` file you can configure the behaviour, content, and the look and feel of the sidebar table of contents.
You can also disable the feature completely.

Expand Down
2 changes: 1 addition & 1 deletion docs/digging-deeper/advanced-markdown.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
navigation:
label: "Advanced Markdown"
priority: 26
priority: 27
---

# Advanced Markdown
Expand Down
145 changes: 1 addition & 144 deletions docs/digging-deeper/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Still, you will likely want to customize some parts of these menus, and thankful
- To customize the navigation menu, use the setting `navigation.order` in the `hyde.php` config.
- When customizing the navigation menu, you should use the [route key](core-concepts#route-keys) of the page.

Learn more in the [Navigation Menu](navigation-menus) documentation.
Learn more in the [Navigation Menu](navigation) documentation.

#### Customizing the documentation sidebar

Expand All @@ -221,149 +221,6 @@ Learn more in the [Navigation Menu](navigation-menus) documentation.

Learn more in the [Documentation Pages](documentation-pages) documentation.

>info Tip: When using subdirectory-based dropdowns, you can set their priority using the directory name as the array key.
### Primer on priorities

All navigation menu items have an internal priority value that determines its order in the navigation.
Lower values means that the item will be higher up in the menu. The default for pages is `999` which puts them last.
However, some pages are autoconfigured to have a lower priority, for example, the `index` page defaults to a priority of `0`,

#### Basic syntax for changing the priorities

The cleanest way is to use the list-style syntax where each item will get the priority calculated according to its position in the list, plus an offset of `500`.
The offset is added to make it easier to place pages earlier in the list using front matter or with explicit priority settings.

```php
[
'readme', // Gets priority 500
'installation', // Gets priority 501
'getting-started', // Gets priority 502
]
```

#### Explicit syntax for changing the priorities

You can also specify explicit priorities by adding a value to the array key:

```php
[
'readme' => 10, // Gets priority 10
'installation' => 15, // Gets priority 15
'getting-started' => 20, // Gets priority 20
]
```

You can also combine these options if you want:

```php
[
'readme' => 10, // Gets priority 10
'installation', // Gets priority 500
'getting-started', // Gets priority 501
]
```

You can also set the priority of a page directly in the front matter. This will override any dynamically inferred or
config defined priority. While this is useful for one-offs, it can make it harder to reorder items later on.
It's up to you which method you prefer to use. This setting can be used both for the navigation menu and the sidebar.

```markdown
---
navigation:
priority: 25
---
```

#### Changing the menu item labels

Hyde makes a few attempts to find a suitable label for the navigation menu items to automatically create helpful titles.
You can override the label using the `navigation.label` front matter property.

From the Hyde config you can also override the label of navigation links using the by mapping the route key
to the desired title. Note that the front matter property will take precedence over the config property.

```php
// filepath config/hyde.php
'navigation' => [
'labels' => [
'index' => 'Start',
'docs/index' => 'Documentation',
]
]
```

#### Excluding Items (Blacklist)

Sometimes, especially if you have a lot of pages, you may want to prevent links from showing up in the main navigation menu.
To remove items from being automatically added, simply add the page's route key to the blacklist.
As you can see, the `404` page has already been filled in for you.

```php
// filepath config/hyde.php
'navigation' => [
'exclude' => [
'404'
]
]
```

You can also specify that a page should be excluded by setting the page front matter.

```markdown
---
navigation:
hidden: true
---
```

#### Adding Custom Navigation Menu Links

You can easily add custom navigation menu links similar how we add Authors. Simply add a `NavItem` model to the `navigation.custom` array.

When linking to an external site, you should use the `NavItem::forLink()` method facade. The first two arguments are the
destination and label, both required. Third argument is the priority, which is optional, and defaults to 500.

```php
// filepath config/hyde.php
use Hyde\Framework\Features\Navigation\NavItem;

'navigation' => [
'custom' => [
NavItem::forLink('https://github.com/hydephp/hyde', 'GitHub', 200),
]
]
```

Simplified, this will then be rendered as follows:

```html
<a href="https://github.com/hydephp/hyde">GitHub</a>
```

#### Automatic navigation menu dropdowns

HydePHP has a neat feature to automatically place pages in dropdowns based on subdirectories.

For pages that can be in the main site menu, ths feature needs to be enabled in the `hyde.php` config file.

```php
// filepath config/hyde.php

'navigation' => [
'subdirectories' => 'dropdown',
],
```

Now if you create a page called `_pages/about/contact.md` it will automatically be placed in a dropdown called "About".

#### Automatic documentation sidebar grouping

This feature works similarly to the automatic navigation menu dropdowns, but instead place the sidebar items in named groups.
This feature is enabled by default, so you only need to place your pages in subdirectories to have them grouped.

For example: `_docs/getting-started/installation.md` will be placed in a group called "Getting Started".

## Additional Advanced Options

The following configuration options in the `confg/hyde.php` file are intended for advanced users and
Expand Down
Loading

0 comments on commit a4313b2

Please sign in to comment.