Skip to content

Commit 7b6a7ad

Browse files
authored
Merge pull request #1568 from hydephp/improved-navigation-internals
[2.x] Rewrite navigation internals
2 parents c42d912 + cc2756e commit 7b6a7ad

File tree

63 files changed

+5617
-1348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5617
-1348
lines changed

RELEASE_NOTES.md

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ This serves two purposes:
1313
- Added a new `\Hyde\Framework\Actions\PreBuildTasks\TransferMediaAssets` build task handle media assets transfers for site builds.
1414

1515
### Changed
16+
- **Breaking:** The internals of the navigation system has been rewritten into a new Navigation API. This change is breaking for custom navigation implementations. For more information, see below.
17+
- Minor: Navigation menu items are now no longer filtered by duplicates (meaning two items with the same label can now exist in the same menu) in https://github.com/hydephp/develop/pull/1573
18+
- Minor: Due to changes in the navigation system, it is possible that existing configuration files will need to be adjusted in order for menus to look the same (in terms of ordering etc.)
19+
- Minor: The documentation article component now supports disabling the semantic rendering using a falsy value in https://github.com/hydephp/develop/pull/1566
1620
- Changed how the documentation search is generated, to be an `InMemoryPage` instead of a post-build task.
1721
- Media asset files are now copied using the new build task instead of the deprecated `BuildService::transferMediaAssets()` method.
18-
- Minor: The documentation article component now supports disabling the semantic rendering using a falsy value in https://github.com/hydephp/develop/pull/1566
1922

2023
### Deprecated
2124
- for soon-to-be removed features.
@@ -41,6 +44,32 @@ Please see the "Breaking changes & upgrade guide" section below for more informa
4144

4245
Please read through this section to ensure your site upgrades smoothly.
4346

47+
## High impact
48+
49+
### Navigation system rewrite
50+
51+
The navigation system has been rewritten into a new Navigation API. This change is breaking for custom navigation implementations, see more down below.
52+
53+
For most users, the only impact will be that configuration files need to be updated to use the new configuration format. Due to the internal changes,
54+
it's also possible that menu items will be in a slightly different order than before, depending on your setup. Please verify that your site's menus
55+
look as expected after upgrading, and adjust the configuration files if necessary, before deploying to production.
56+
57+
### Navigation and sidebar configuration changes
58+
59+
The navigation and sidebar configuration files have been updated to use the new Navigation API.
60+
This means that you will need to update your configuration files to use the new format.
61+
62+
The easiest way to upgrade is to publish updated configuration files (`hyde.php` and `docs.php`) and copy over your customizations.
63+
64+
The following configuration entries have been updated:
65+
66+
- Changed configuration option `docs.sidebar_order` to `docs.sidebar.order` in https://github.com/hydephp/develop/pull/1583
67+
- Upgrade path: Move the `sidebar_order` option's array in the `config/docs.php` file into the `sidebar` array in the same file.
68+
69+
- Changed configuration option `docs.table_of_contents` to `docs.sidebar.table_of_contents` in https://github.com/hydephp/develop/pull/1584
70+
- Upgrade path: Move the `table_of_contents` option's array in the `config/docs.php` file into the `sidebar` array in the same file.
71+
72+
4473
## General impact
4574

4675
### Documentation search page changes
@@ -49,26 +78,55 @@ The documentation search page and search index have been changed to be generated
4978

5079
The main impact noticeable to most users by this is the implicit changes, like the pages showing up in the dashboard and route list command.
5180

52-
In case you have customized the `GenerateSearch` post-build task you may, depending on what you were trying to do,
81+
In case you have customized the `GenerateSearch` post-build task you may, depending on what you were trying to do,
5382
want to adapt your code to interact with the new `InMemoryPage`, which is generated in the `HydeCoreExtension` class.
5483

5584
For more information, see https://github.com/hydephp/develop/pull/1498.
5685

5786
## Low impact
5887

88+
### Navigation internal changes
89+
90+
The navigation system has been rewritten into a new Navigation API. This change is breaking for custom navigation implementations.
91+
92+
If you have previously in your custom code done any of the following, or similar, you will need to adapt your code to use the new Navigation API:
93+
- Created custom navigation menus or Blade components
94+
- Extended or called the navigation related classes directly
95+
- Customized the navigation system in any way beyond the standard configuration
96+
97+
98+
#### Upgrade guide
99+
100+
Due to the scope of the rewrite, the easiest and fastest way to upgrade your code is to recreate it using the new Navigation API.
101+
102+
- For a full comparison of the changes, you may see the PR that introduced the new API: https://github.com/hydephp/develop/pull/1568/files
103+
- For information on how to use the new Navigation API, see the documentation: https://hydephp.com/docs/2.x/navigation-api
104+
105+
### HTML ID changes
106+
107+
Some HTML IDs have been renamed to follow a more consistent naming convention.
108+
109+
If you have used any of the following selectors in custom code you wrote yourself, you will need to update to use the new changed IDs.
110+
111+
#### https://github.com/hydephp/develop/pull/1622
112+
- Rename HTML ID `#searchMenu` to `#search-menu`
113+
- Rename HTML ID `#searchMenuButton` to `#search-menu-button`
114+
- Rename HTML ID `#searchMenuButtonMobile` to `#search-menu-button-mobile`
115+
116+
59117
### New documentation search implementation
60118

61119
As the new documentation search implementation brings changes to their code API you may need to adapt your code
62120
according to the information below in case you wrote custom code that interacted with these parts of the codebase.
63121

64-
- The `GenerateSearch` post-build task has been removed. If you have previously extended or customized this class,
122+
- The `GenerateSearch` post-build task has been removed. If you have previously extended or customized this class,
65123
you will need to adapt your code, as the search index files are now handled implicitly during the standard build process,
66124
as the search pages are now added to the kernel page and route collection. (https://github.com/hydephp/develop/pull/1498)
67125

68126
- If your site has a custom documentation search page, for example `_docs/search.md` or `_pages/docs/search.blade.php`,
69-
that page will no longer be built when using the specific `build:search` command. It will, of course,
127+
that page will no longer be built when using the specific `build:search` command. It will, of course,
70128
be built using the standard `build` command. https://github.com/hydephp/develop/commit/82dc71f4a0e7b6be7a9f8d822fbebe39d2289ced
71-
129+
72130
- In the highly unlikely event your site customizes any of the search pages by replacing them in the kernel route collection,
73131
you would now need to do that in the kernel page collection due to the search pages being generated earlier in the lifecycle.
74132
https://github.com/hydephp/develop/commit/82dc71f4a0e7b6be7a9f8d822fbebe39d2289ced

_ide_helper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
/** @var string $routeKey The route key for the page being compiled/previewed */
2323
$routeKey = \Hyde\Support\Facades\Render::getRouteKey();
2424

25+
// Variables available only to some page types
26+
27+
/** @var \Hyde\Framework\Features\Navigation\DocumentationSidebar $sidebar */
28+
$sidebar = app('navigation.sidebar');
29+
2530
// Facades (aliased in app/config.php)
2631

2732
/** @mixin \Hyde\Foundation\HydeKernel */

app/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
Hyde\Foundation\Providers\ConfigurationServiceProvider::class,
7474
Hyde\Framework\HydeServiceProvider::class,
7575
Hyde\Foundation\Providers\ViewServiceProvider::class,
76+
Hyde\Foundation\Providers\NavigationServiceProvider::class,
7677
Hyde\Console\ConsoleServiceProvider::class,
7778
],
7879

config/docs.php

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,49 +30,49 @@
3030
// When using a grouped sidebar, should the groups be collapsible?
3131
'collapsible' => true,
3232

33-
// Should the sidebar footer be shown? You can also set this to a string
34-
// of Markdown to show in the footer. Set to `false` to disable.
35-
'footer' => true,
36-
],
37-
38-
/*
39-
|--------------------------------------------------------------------------
40-
| Sidebar Page Order
41-
|--------------------------------------------------------------------------
42-
|
43-
| In the generated Documentation pages the navigation links in the sidebar
44-
| default to sort alphabetically. You can reorder the page identifiers
45-
| in the list below, and the links will get sorted in that order.
46-
|
47-
| The items will get a priority of 500 plus the order its found in the list.
48-
| Pages without a priority will fall back to the default priority of 999.
49-
|
50-
| You can also set explicit priorities in front matter or by specifying
51-
| a value to the array key in the list to override the inferred value.
52-
|
53-
*/
54-
55-
'sidebar_order' => [
56-
'readme',
57-
'installation',
58-
'getting-started',
59-
],
60-
61-
/*
62-
|--------------------------------------------------------------------------
63-
| Table of Contents Settings
64-
|--------------------------------------------------------------------------
65-
|
66-
| The Hyde Documentation Module comes with a fancy Sidebar that, by default,
67-
| has a Table of Contents included. Here, you can configure its behavior,
68-
| content, look and feel. You can also disable the feature completely.
69-
|
70-
*/
33+
// A string of Markdown to show in the footer. Set to `false` to disable.
34+
'footer' => '[Back to home page](../)',
35+
36+
/*
37+
|--------------------------------------------------------------------------
38+
| Sidebar Page Order
39+
|--------------------------------------------------------------------------
40+
|
41+
| In the generated Documentation pages the navigation links in the sidebar
42+
| default to sort alphabetically. You can reorder the page identifiers
43+
| in the list below, and the links will get sorted in that order.
44+
|
45+
| The items will get a priority of 500 plus the order its found in the list.
46+
| Pages without a priority will fall back to the default priority of 999.
47+
|
48+
| You can also set explicit priorities in front matter or by specifying
49+
| a value to the array key in the list to override the inferred value.
50+
|
51+
*/
52+
53+
'order' => [
54+
'readme',
55+
'installation',
56+
'getting-started',
57+
],
58+
59+
/*
60+
|--------------------------------------------------------------------------
61+
| Table of Contents Settings
62+
|--------------------------------------------------------------------------
63+
|
64+
| The Hyde Documentation Module comes with a fancy Sidebar that, by default,
65+
| has a Table of Contents included. Here, you can configure its behavior,
66+
| content, look and feel. You can also disable the feature completely.
67+
|
68+
*/
69+
70+
'table_of_contents' => [
71+
'enabled' => true,
72+
'min_heading_level' => 2,
73+
'max_heading_level' => 4,
74+
],
7175

72-
'table_of_contents' => [
73-
'enabled' => true,
74-
'min_heading_level' => 2,
75-
'max_heading_level' => 4,
7676
],
7777

7878
/*

config/hyde.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@
350350
// To get started quickly, you can uncomment the defaults here.
351351
// See the documentation link above for more information.
352352
'custom' => [
353-
// NavItem::forLink('https://github.com/hydephp/hyde', 'GitHub', 200),
353+
// NavigationItem::create('https://github.com/hydephp/hyde', 'GitHub', 200),
354354
],
355355

356356
// How should pages in subdirectories be displayed in the menu?

0 commit comments

Comments
 (0)