Skip to content

Commit 01bc43f

Browse files
authored
Merge pull request #1451 from hydephp/navigation-documentation-updates
Update navigation documentation
2 parents 0594ddc + 1dfbb07 commit 01bc43f

File tree

3 files changed

+69
-65
lines changed

3 files changed

+69
-65
lines changed

docs/architecture-concepts/architecture-concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ navigation:
88

99
## Introduction
1010

11-
These chapters are written for power users and contributors. If you're just looking to get a site up and running,
11+
These chapters are written for power users and package contributors. If you're just looking to get a site up and running,
1212
you can safely skip this section. The documentation here will cover advanced topics under the presumption that
1313
the reader has a basic to intermediate understanding of programming, as well as PHP, object-oriented design,
1414
and to some extent Laravel, as the articles are heavily driven by code examples.

docs/creating-content/documentation-pages.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,12 @@ By default, a link to the documentation page is added to the navigation menu whe
199199
### Sidebar header name
200200

201201
By default, the site title shown in the sidebar header is generated from the configured site name suffixed with "docs".
202-
You can change this in the Docs configuration file.
202+
You can change this in the Docs configuration file. Tip: The header will link to the docs/index page, if it exists.
203203

204204
```php
205205
'title' => 'API Documentation',
206206
```
207207

208-
>info Tip: The header will link to the docs/index page, if it exists.
209-
210208
### Sidebar page order
211209

212210
To quickly arrange the order of items in the sidebar, you can reorder the page identifiers in the list and the links will be sorted in that order.

docs/digging-deeper/customization.md

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ In some cases, the same options can be set in the front matter of a page or in a
5656
### A note on file paths
5757

5858
When Hyde references files, especially when passing filenames between components, the file path is almost always
59-
relative to the root of the project. Specifying absolute paths yourself will likely lead to unforeseen problems.
59+
relative to the root of the project. Specifying absolute paths yourself could lead to unforeseen problems.
6060

6161

6262
## Configuration Files Overview
@@ -202,57 +202,65 @@ If you don't want to have a footer on your site, you can set the `'footer'` conf
202202

203203
### Navigation Menu & Sidebar
204204

205-
One of my favourite features with Hyde is its automatic navigation menu and documentation sidebar generator.
205+
A great time-saving feature of HydePHP is the automatic navigation menu and documentation sidebar generation.
206+
Hyde is designed to automatically configure these menus for you based on the content you have in your project.
206207

207-
#### How it works:
208+
Still, you will likely want to customize some parts of these menus, and thankfully, Hyde makes it easy to do so.
208209

209-
The sidebar works by creating a list of all the documentation pages.
210+
#### Customizing the navigation menu
210211

211-
The navigation menu is a bit more sophisticated, it adds all the top-level Blade and Markdown pages.
212-
It also adds an automatic link to the docs if there is an `index.md` in the `_docs` directory.
212+
- To customize the navigation menu, use the setting `navigation.order` in the `hyde.php` config.
213+
- When customizing the navigation menu, you should use the [route key](core-concepts#route-keys) of the page.
213214

214-
#### Reordering Sidebar Items
215+
Learn more in the [Navigation Menu](navigation-menus) documentation.
215216

216-
Sadly, Hyde is not intelligent enough to determine what order items should be in (blame Dr Jekyll for this),
217-
so you will probably want to set a custom order.
217+
#### Customizing the documentation sidebar
218218

219-
Reordering items in the documentation sidebar is as easy as can be. In the `docs` config, there is an array just for this.
220-
If a page identifier is found here it will get priority calculated according to its position in the list,
221-
plus an offset of 500. This offset allows you to pages earlier in the list using front matter.
219+
- To customize the sidebar, use the setting `sidebar_order` in the `docs.php` config.
220+
- When customizing the sidebar, can use the route key, or just the [page identifier](core-concepts#page-identifiers) of the page.
222221

223-
If a page does not exist in the list they get priority 999, which puts them last.
224-
You can also use front matter to set a priority for a page.
225-
The front matter value will always take precedence.
222+
Learn more in the [Documentation Pages](documentation-pages) documentation.
226223

227-
Let's see an example:
224+
>info Tip: When using subdirectory-based dropdowns, you can set their priority using the directory name as the array key.
225+
226+
### Primer on priorities
227+
228+
All navigation menu items have an internal priority value that determines its order in the navigation.
229+
Lower values means that the item will be higher up in the menu. The default for pages is `999` which puts them last.
230+
However, some pages are autoconfigured to have a lower priority, for example, the `index` page defaults to a priority of `0`,
231+
232+
#### Basic syntax for changing the priorities
233+
234+
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`.
235+
The offset is added to make it easier to place pages earlier in the list using front matter or with explicit priority settings.
228236

229237
```php
230-
// filepath: config/docs.php
231-
// These are the default values in the config. It puts the readme.md first in order.
232-
'sidebar_order' => [
233-
'readme', // This is the first entry, so it gets the priority 500 + 0
234-
'installation', // This gets priority 500 + 1
235-
'getting-started', // And this gets priority 500 + 2
236-
// Any other pages not listed will get priority 999
238+
[
239+
'readme', // Gets priority 500
240+
'installation', // Gets priority 501
241+
'getting-started', // Gets priority 502
237242
]
238243
```
239244

240-
#### Reordering Navigation Menu Items
245+
#### Explicit syntax for changing the priorities
241246

242-
As Hyde makes an effort to organize the menu items in a sensible way, your project comes preconfigured to put what it thinks are your most
243-
important pages first. This may of course not always match what you want, so thankfully it's easy to reorder the menu items!
247+
You can also specify explicit priorities by adding a value to the array key:
248+
249+
```php
250+
[
251+
'readme' => 10, // Gets priority 10
252+
'installation' => 15, // Gets priority 15
253+
'getting-started' => 20, // Gets priority 20
254+
]
255+
```
244256

245-
Simply update the `navigation.order` array in the Hyde config! The priorities set will determine the order of the menu items.
246-
Lower values are higher in the menu, and any pages not listed will get priority 999, which puts them last.
257+
You can also combine these options if you want:
247258

248259
```php
249-
// filepath config/hyde.php
250-
'navigation' => [
251-
'order' => [
252-
'index' => 0, // _pages/index.md (or .blade.php)
253-
'posts' => 10, // _pages/posts.md (or .blade.php)
254-
'docs/index' => 100, // _docs/index.md
255-
]
260+
[
261+
'readme' => 10, // Gets priority 10
262+
'installation', // Gets priority 500
263+
'getting-started', // Gets priority 501
256264
]
257265
```
258266

@@ -263,43 +271,36 @@ It's up to you which method you prefer to use. This setting can be used both for
263271
```markdown
264272
---
265273
navigation:
266-
priority: 10
274+
priority: 25
267275
---
268276
```
269277

270-
>info Tip: If you are using automatic subdirectory dropdowns, you can also set their priority in the config. Just use the directory name instead of the page identifier.
271-
272-
#### Adding Custom Navigation Menu Links
278+
#### Changing the menu item labels
273279

274-
You can easily add custom navigation menu links similar how we add Authors. Simply add a `NavItem` model to the `navigation.custom` array.
280+
Hyde makes a few attempts to find a suitable label for the navigation menu items to automatically create helpful titles.
281+
You can override the label using the `navigation.label` front matter property.
275282

276-
When linking to an external site, you should use the `NavItem::forLink()` method facade. The first two arguments are the
277-
destination and label, both required. Third argument is the priority, which is optional, and defaults to 500.
283+
From the Hyde config you can also override the label of navigation links using the by mapping the route key
284+
to the desired title. Note that the front matter property will take precedence over the config property.
278285

279286
```php
280287
// filepath config/hyde.php
281-
use Hyde\Framework\Features\Navigation\NavItem;
282-
283288
'navigation' => [
284-
'custom' => [
285-
NavItem::forLink('https://github.com/hydephp/hyde', 'GitHub', 200),
289+
'labels' => [
290+
'index' => 'Start',
291+
'docs/index' => 'Documentation',
286292
]
287293
]
288294
```
289295

290-
Simplified, this will then be rendered as follows:
291-
292-
```html
293-
<a href="https://github.com/hydephp/hyde">GitHub</a>
294-
```
295-
296296
#### Excluding Items (Blacklist)
297297

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

302302
```php
303+
// filepath config/hyde.php
303304
'navigation' => [
304305
'exclude' => [
305306
'404'
@@ -314,26 +315,31 @@ You can also specify that a page should be excluded by setting the page front ma
314315
navigation:
315316
hidden: true
316317
---
317-
```
318318

319-
#### Changing the menu item labels
320319

321-
Hyde makes a few attempts to find a suitable label for the navigation menu items to automatically create helpful titles.
322-
You can override the label using the `navigation.label` front matter property.
320+
#### Adding Custom Navigation Menu Links
323321

324-
From the Hyde config you can also override the label of navigation links using the by mapping the route key
325-
to the desired title. Note that the front matter property will take precedence over the config property.
322+
You can easily add custom navigation menu links similar how we add Authors. Simply add a `NavItem` model to the `navigation.custom` array.
323+
324+
When linking to an external site, you should use the `NavItem::forLink()` method facade. The first two arguments are the
325+
destination and label, both required. Third argument is the priority, which is optional, and defaults to 500.
326326

327327
```php
328328
// filepath config/hyde.php
329+
use Hyde\Framework\Features\Navigation\NavItem;
330+
329331
'navigation' => [
330-
'labels' => [
331-
'index' => 'Start',
332-
'docs/index' => 'Documentation',
332+
'custom' => [
333+
NavItem::forLink('https://github.com/hydephp/hyde', 'GitHub', 200),
333334
]
334335
]
335336
```
336337

338+
Simplified, this will then be rendered as follows:
339+
340+
```html
341+
<a href="https://github.com/hydephp/hyde">GitHub</a>
342+
```
337343

338344
## Blade Views
339345

0 commit comments

Comments
 (0)