Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dedicated navigation documentation page #1540

Merged
merged 42 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bfe999e
Create navigation.md
caendesilva Feb 8, 2024
2f7cab8
Add front matter
caendesilva Feb 8, 2024
0829750
Offset navigation priorities
caendesilva Feb 8, 2024
6716b5c
Update title
caendesilva Feb 8, 2024
7454bd6
Add introduction section
caendesilva Feb 8, 2024
aa67176
Fix broken link
caendesilva Feb 8, 2024
c38ca91
Add primer on the internals
caendesilva Feb 8, 2024
5ceef93
Add internals deep dive
caendesilva Feb 8, 2024
aa4d3bb
Add high level overview of option types
caendesilva Feb 8, 2024
c0f748f
Improve grammar and wording
caendesilva Feb 8, 2024
3aecc7d
Add additional background section
caendesilva Feb 9, 2024
c3143a9
Add overview section
caendesilva Feb 9, 2024
9d304d3
Formatting
caendesilva Feb 9, 2024
15ced66
Formatting
caendesilva Feb 9, 2024
f53ada0
Document all the front matter options
caendesilva Feb 9, 2024
48fed8d
Begin section
caendesilva Feb 9, 2024
1fa5c7d
Increase subheading levels
caendesilva Feb 9, 2024
b74be43
Move priorities primer to new page
caendesilva Feb 9, 2024
d9c285e
Move context to new page
caendesilva Feb 9, 2024
fc620d2
Add new heading
caendesilva Feb 9, 2024
92f40f4
Add new basic syntax documentation
caendesilva Feb 9, 2024
96f5bb2
Document explicit syntax
caendesilva Feb 9, 2024
10ddfe0
Remove overlapping documentation
caendesilva Feb 9, 2024
e0d0b6f
Update link
caendesilva Feb 9, 2024
fe27b8f
Clarify section
caendesilva Feb 9, 2024
3950586
Note overrides
caendesilva Feb 9, 2024
fc6a0fc
Move label config documentation
caendesilva Feb 9, 2024
4f484cd
Cleaner heading
caendesilva Feb 9, 2024
87d452e
Move documentation
caendesilva Feb 9, 2024
89f491f
Move documentation
caendesilva Feb 9, 2024
c43b126
Lower heading levels
caendesilva Feb 9, 2024
901545b
Document subdirectory handling
caendesilva Feb 9, 2024
ff616ba
Move subdirectory docs
caendesilva Feb 9, 2024
e795f65
Adjust headings
caendesilva Feb 9, 2024
9fdae5e
Formatting
caendesilva Feb 9, 2024
59dc515
Revert "Update link"
caendesilva Feb 9, 2024
adb7289
Merge duplicated section
caendesilva Feb 9, 2024
afa8fc4
New introduction section
caendesilva Feb 9, 2024
9bc1dbc
Move helper note
caendesilva Feb 9, 2024
b6a5a26
Fix grammar and spelling
caendesilva Feb 9, 2024
c3a5990
Merge branch 'master' into add-dedicated-navigation-documentation-page
caendesilva Feb 9, 2024
d003297
Formatting
caendesilva Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading