You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/digging-deeper/customization.md
+67-61Lines changed: 67 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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
56
56
### A note on file paths
57
57
58
58
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.
60
60
61
61
62
62
## 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
202
202
203
203
### Navigation Menu & Sidebar
204
204
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.
206
207
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.
208
209
209
-
The sidebar works by creating a list of all the documentation pages.
210
+
#### Customizing the navigation menu
210
211
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.
213
214
214
-
#### Reordering Sidebar Items
215
+
Learn more in the [Navigation Menu](navigation-menus) documentation.
215
216
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
218
218
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.
222
221
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.
226
223
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.
228
236
229
237
```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
237
242
]
238
243
```
239
244
240
-
#### Reordering Navigation Menu Items
245
+
#### Explicit syntax for changing the priorities
241
246
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
+
```
244
256
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:
247
258
248
259
```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
256
264
]
257
265
```
258
266
@@ -263,43 +271,36 @@ It's up to you which method you prefer to use. This setting can be used both for
263
271
```markdown
264
272
---
265
273
navigation:
266
-
priority: 10
274
+
priority: 25
267
275
---
268
276
```
269
277
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
273
279
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.
275
282
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.
0 commit comments