From bef49fc188e28dfc7c0bae04d9fb6ee4e32473cb Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:24:12 +0200 Subject: [PATCH 01/38] Format to PSR2 --- packages/framework/src/Commands/HydeBuildSearchCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Commands/HydeBuildSearchCommand.php b/packages/framework/src/Commands/HydeBuildSearchCommand.php index 372a9dea3ca..3f2f2263b90 100644 --- a/packages/framework/src/Commands/HydeBuildSearchCommand.php +++ b/packages/framework/src/Commands/HydeBuildSearchCommand.php @@ -49,12 +49,14 @@ public function handle(): int if (config('docs.create_search_page', true)) { $this->action('Generating search page', function () { file_put_contents( - Hyde::path(sprintf('_site/%s/search.html', + Hyde::path(sprintf( + '_site/%s/search.html', config('docs.output_directory', 'docs') )), view('hyde::pages.documentation-search')->render() ); - }, sprintf('Created _site/%s/search.html', + }, sprintf( + 'Created _site/%s/search.html', config('docs.output_directory', 'docs') )); } From 012948c982a92f518ebf162948e6f20b9365b80d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:27:45 +0200 Subject: [PATCH 02/38] Annotate string type as multi choice is not enabled --- packages/framework/src/Commands/HydePublishHomepageCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/src/Commands/HydePublishHomepageCommand.php b/packages/framework/src/Commands/HydePublishHomepageCommand.php index 3e66b5cb947..fff4ca81186 100644 --- a/packages/framework/src/Commands/HydePublishHomepageCommand.php +++ b/packages/framework/src/Commands/HydePublishHomepageCommand.php @@ -55,6 +55,7 @@ public function handle(): int protected function promptForHomepage(): string { + /** @var string $choice */ $choice = $this->choice( 'Which homepage do you want to publish?', $this->formatPublishableChoices(), From 204d9fd3a2bdc3a4f968cb3bb52907ec00d74391 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:29:04 +0200 Subject: [PATCH 03/38] Annotate string type as multi choice is not enabled --- packages/framework/src/Commands/HydePublishViewsCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/src/Commands/HydePublishViewsCommand.php b/packages/framework/src/Commands/HydePublishViewsCommand.php index 48851963abb..0fccd42603a 100644 --- a/packages/framework/src/Commands/HydePublishViewsCommand.php +++ b/packages/framework/src/Commands/HydePublishViewsCommand.php @@ -46,6 +46,7 @@ protected function publishOption(string $selected): void protected function promptForCategory(): string { + /** @var string $choice */ $choice = $this->choice( 'Which category do you want to publish?', $this->formatPublishableChoices(), From d119580d4bf22694b9eeeee16e53c1a94b83827f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:31:03 +0200 Subject: [PATCH 04/38] Convert concatenation to scalar value --- packages/framework/src/Commands/HydePublishViewsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Commands/HydePublishViewsCommand.php b/packages/framework/src/Commands/HydePublishViewsCommand.php index 0fccd42603a..4ac1791952f 100644 --- a/packages/framework/src/Commands/HydePublishViewsCommand.php +++ b/packages/framework/src/Commands/HydePublishViewsCommand.php @@ -41,7 +41,7 @@ protected function publishOption(string $selected): void $to = (PublishesHydeViews::$options[$selected]['destination']); - $this->line('Copied ['."$from".'] to ['."$to".']'); + $this->line("Copied [$from] to [$to]"); } protected function promptForCategory(): string From 7380b83d7f5fa17a69f0e94696d0b417b4d59531 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:32:42 +0200 Subject: [PATCH 05/38] Convert concatenation to 'sprintf()' call --- packages/framework/src/Commands/HydePublishViewsCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Commands/HydePublishViewsCommand.php b/packages/framework/src/Commands/HydePublishViewsCommand.php index 4ac1791952f..c0f131315e8 100644 --- a/packages/framework/src/Commands/HydePublishViewsCommand.php +++ b/packages/framework/src/Commands/HydePublishViewsCommand.php @@ -55,7 +55,10 @@ protected function promptForCategory(): string $choice = $this->parseChoiceIntoKey($choice); - $this->line('Selected category ['.(empty($choice) ? 'all' : $choice).']'); + $this->line(sprintf( + 'Selected category [%s]', + empty($choice) ? 'all' : $choice + )); $this->newLine(); return $choice; From 37905449bf9e2a954ac8663bab07425249f871c6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:33:43 +0200 Subject: [PATCH 06/38] Merge newline method call into string --- packages/framework/src/Commands/HydePublishViewsCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/framework/src/Commands/HydePublishViewsCommand.php b/packages/framework/src/Commands/HydePublishViewsCommand.php index c0f131315e8..e78c9c09fc4 100644 --- a/packages/framework/src/Commands/HydePublishViewsCommand.php +++ b/packages/framework/src/Commands/HydePublishViewsCommand.php @@ -56,10 +56,9 @@ protected function promptForCategory(): string $choice = $this->parseChoiceIntoKey($choice); $this->line(sprintf( - 'Selected category [%s]', + "Selected category [%s]\n", empty($choice) ? 'all' : $choice )); - $this->newLine(); return $choice; } From 1fb5f7c8de76f50141dcfa8363a43aa655835f7e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:40:46 +0200 Subject: [PATCH 07/38] HydeRC is not really experimental anymore --- packages/framework/src/Commands/HydeServeCommand.php | 4 +--- .../framework/tests/Feature/Commands/HydeServeCommandTest.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/framework/src/Commands/HydeServeCommand.php b/packages/framework/src/Commands/HydeServeCommand.php index 3d3eb1829ac..e07e1b325cf 100644 --- a/packages/framework/src/Commands/HydeServeCommand.php +++ b/packages/framework/src/Commands/HydeServeCommand.php @@ -31,9 +31,7 @@ class HydeServeCommand extends Command */ public function handle(): int { - $this->line('Starting the server... Press Ctrl+C to stop'); - - $this->warn('Running experimental HydeRC 2.0. Please report any issues on GitHub.'); + $this->line('Starting the HydeRC server... Press Ctrl+C to stop'); $port = $this->option('port'); $host = $this->option('host'); diff --git a/packages/framework/tests/Feature/Commands/HydeServeCommandTest.php b/packages/framework/tests/Feature/Commands/HydeServeCommandTest.php index 07a69021d42..39ff7b07829 100644 --- a/packages/framework/tests/Feature/Commands/HydeServeCommandTest.php +++ b/packages/framework/tests/Feature/Commands/HydeServeCommandTest.php @@ -12,7 +12,7 @@ class HydeServeCommandTest extends TestCase public function test_hyde_serve_command() { $this->artisan('serve') - ->expectsOutput('Starting the server... Press Ctrl+C to stop') + ->expectsOutput('Starting the HydeRC server... Press Ctrl+C to stop') ->assertExitCode(0); } } From 0d9260866c2848077c66f6c91f1a311fef625040 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:43:24 +0200 Subject: [PATCH 08/38] Non-static method should not be called statically --- packages/framework/src/Contracts/AbstractPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Contracts/AbstractPage.php b/packages/framework/src/Contracts/AbstractPage.php index f5c72b10b94..f4cb48db220 100644 --- a/packages/framework/src/Contracts/AbstractPage.php +++ b/packages/framework/src/Contracts/AbstractPage.php @@ -145,7 +145,7 @@ public function getSourcePath(): string /** @inheritDoc */ public function getOutputPath(): string { - return static::getCurrentPagePath().'.html'; + return $this->getCurrentPagePath().'.html'; } /** @inheritDoc */ From 775d8b39d1d8687d8b0b7c7a4cbc27248d2edcd3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:44:58 +0200 Subject: [PATCH 09/38] Add additional type check to confirm key is not null --- packages/framework/src/Contracts/AbstractPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Contracts/AbstractPage.php b/packages/framework/src/Contracts/AbstractPage.php index f4cb48db220..a8612aeafa9 100644 --- a/packages/framework/src/Contracts/AbstractPage.php +++ b/packages/framework/src/Contracts/AbstractPage.php @@ -107,7 +107,7 @@ public static function getOutputLocation(string $basename): string /** @inheritDoc */ public function get(string $key = null, mixed $default = null): mixed { - if (property_exists($this, $key) && isset($this->$key)) { + if ($key !== null && property_exists($this, $key) && isset($this->$key)) { return $this->$key; } From a9779c724a374a965a3f08aaf2c8cadd80456537 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:46:42 +0200 Subject: [PATCH 10/38] Change return type false to bool as method may return true --- packages/framework/src/Services/RssFeedService.php | 2 +- packages/framework/src/Services/SitemapService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Services/RssFeedService.php b/packages/framework/src/Services/RssFeedService.php index 6c6a151d832..3733a18b55a 100644 --- a/packages/framework/src/Services/RssFeedService.php +++ b/packages/framework/src/Services/RssFeedService.php @@ -43,7 +43,7 @@ public function generate(): static return $this; } - public function getXML(): string|false + public function getXML(): string|bool { return $this->feed->asXML(); } diff --git a/packages/framework/src/Services/SitemapService.php b/packages/framework/src/Services/SitemapService.php index 0fb8ab441b5..bbb15e59440 100644 --- a/packages/framework/src/Services/SitemapService.php +++ b/packages/framework/src/Services/SitemapService.php @@ -44,7 +44,7 @@ public function generate(): static return $this; } - public function getXML(): string|false + public function getXML(): string|bool { $this->xmlElement->addAttribute('processing_time_ms', (string) round((microtime(true) - $this->time_start) * 1000, 2)); From c7fd7126105c188e0defe4d06eea720afabbc59e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 18:57:09 +0200 Subject: [PATCH 11/38] Replace implementation type hint with contracted interface --- packages/framework/src/helpers.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/framework/src/helpers.php b/packages/framework/src/helpers.php index ac1b1d04ae4..c0f061ac579 100644 --- a/packages/framework/src/helpers.php +++ b/packages/framework/src/helpers.php @@ -1,16 +1,15 @@ Date: Thu, 11 Aug 2022 19:02:14 +0200 Subject: [PATCH 12/38] Remove duplicate parameter in comment --- packages/framework/src/helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/helpers.php b/packages/framework/src/helpers.php index c0f061ac579..d018d751c96 100644 --- a/packages/framework/src/helpers.php +++ b/packages/framework/src/helpers.php @@ -37,7 +37,7 @@ function unslash(string $string): string * * Unlike array_unique, keys are reset. * - * @param array|\Illuminate\Support\Collection $array $array + * @param array|\Illuminate\Support\Collection $array * @param callable $callback * @return array */ From ae796cf26c41004007bfa036c7086203cbeb8b29 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 19:06:28 +0200 Subject: [PATCH 13/38] Change typed property from Collection to Arrayable This does not affect existing usages, but instead opens up the function for more usages --- packages/framework/src/helpers.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/framework/src/helpers.php b/packages/framework/src/helpers.php index d018d751c96..527474d82af 100644 --- a/packages/framework/src/helpers.php +++ b/packages/framework/src/helpers.php @@ -1,7 +1,7 @@ toArray(); } From 26599df4577c3dbe35d16315a5e56aa48cefc48c Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 11 Aug 2022 17:06:59 +0000 Subject: [PATCH 14/38] Apply fixes from StyleCI --- packages/framework/src/helpers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/helpers.php b/packages/framework/src/helpers.php index 527474d82af..92d8f9a1f26 100644 --- a/packages/framework/src/helpers.php +++ b/packages/framework/src/helpers.php @@ -37,8 +37,8 @@ function unslash(string $string): string * * Unlike array_unique, keys are reset. * - * @param array|\Illuminate\Contracts\Support\Arrayable $array - * @param callable $callback + * @param array|\Illuminate\Contracts\Support\Arrayable $array + * @param callable $callback * @return array */ function array_map_unique(array|Arrayable $array, callable $callback): array From ab1ae3cfe84e5b6c52e1855c84a3c7076880ce5f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 19:12:39 +0200 Subject: [PATCH 15/38] Disable PHPStorm inspection for namespaces needed in output While these namespaces are not used in the file, they are required for the generated output, and are thus false positives. --- packages/framework/src/Services/RssFeedService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/src/Services/RssFeedService.php b/packages/framework/src/Services/RssFeedService.php index 3733a18b55a..ec3c73da555 100644 --- a/packages/framework/src/Services/RssFeedService.php +++ b/packages/framework/src/Services/RssFeedService.php @@ -1,6 +1,7 @@ Date: Thu, 11 Aug 2022 19:18:09 +0200 Subject: [PATCH 16/38] Replace conditional with helper --- packages/framework/src/Services/RssFeedService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Services/RssFeedService.php b/packages/framework/src/Services/RssFeedService.php index ec3c73da555..7b659e60611 100644 --- a/packages/framework/src/Services/RssFeedService.php +++ b/packages/framework/src/Services/RssFeedService.php @@ -76,7 +76,7 @@ protected function addAdditionalItemData(SimpleXMLElement $item, MarkdownPost $p if (isset($post->image)) { $image = $item->addChild('enclosure'); - $image->addAttribute('url', isset($post->image->path) ? Hyde::url('media/'.basename($post->image->path)) : $post->image->getSource()); + $image->addAttribute('url', Hyde::image($post->image, true)); $image->addAttribute('type', str_ends_with($post->image->getSource(), '.png') ? 'image/png' : 'image/jpeg'); $image->addAttribute('length', $post->image->getContentLength()); } From 4d8ea5c8a621dc9b0b06ca46194993a3fae4d494 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 19:28:25 +0200 Subject: [PATCH 17/38] Link to the test that covers the class --- .../src/Actions/Constructors/FindsNavigationDataForPage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index d5f9d417766..9260d21bd4e 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -8,6 +8,9 @@ use Hyde\Framework\Models\Pages\MarkdownPost; use JetBrains\PhpStorm\ArrayShape; +/** + * @see \Hyde\Framework\Testing\Feature\AbstractPageTest + */ class FindsNavigationDataForPage { #[ArrayShape(['title' => 'string', 'hidden' => 'bool', 'priority' => 'int'])] From 0f6f2aac0b25261ae85a78b80f2cfd054acfd74b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 19:29:31 +0200 Subject: [PATCH 18/38] Remove unnecessary type check as all pages have front matter support --- .../Constructors/FindsNavigationDataForPage.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index 9260d21bd4e..ea5bcf630ff 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -64,10 +64,8 @@ protected function getNavigationMenuVisible(): bool return $this->page->identifier === 'index' && ! in_array('docs', config('hyde.navigation.exclude', [])); } - if ($this->page instanceof AbstractMarkdownPage) { - if ($this->page->matter('navigation.hidden', false)) { - return false; - } + if ($this->page->matter('navigation.hidden', false)) { + return false; } if (in_array($this->page->identifier, config('hyde.navigation.exclude', ['404']))) { @@ -79,10 +77,8 @@ protected function getNavigationMenuVisible(): bool protected function getNavigationMenuPriority(): int { - if ($this->page instanceof AbstractMarkdownPage) { - if ($this->page->matter('navigation.priority') !== null) { - return $this->page->matter('navigation.priority'); - } + if ($this->page->matter('navigation.priority') !== null) { + return $this->page->matter('navigation.priority'); } if ($this->page instanceof DocumentationPage) { From b5923b343460ef3288c236ca234aaeda31e8c235 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 11 Aug 2022 17:53:33 +0000 Subject: [PATCH 19/38] Apply fixes from StyleCI --- .../src/Actions/Constructors/FindsNavigationDataForPage.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index ea5bcf630ff..d07aec8cc6e 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -2,7 +2,6 @@ namespace Hyde\Framework\Actions\Constructors; -use Hyde\Framework\Contracts\AbstractMarkdownPage; use Hyde\Framework\Contracts\AbstractPage; use Hyde\Framework\Models\Pages\DocumentationPage; use Hyde\Framework\Models\Pages\MarkdownPost; From a505e4c6d24fd4aa335b3b886435f76ac5f7f38c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 19:59:44 +0200 Subject: [PATCH 20/38] Extract complex code to helper methods --- .../src/Services/MarkdownService.php | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/packages/framework/src/Services/MarkdownService.php b/packages/framework/src/Services/MarkdownService.php index 6ba5c12fac8..de3c2cb66dc 100644 --- a/packages/framework/src/Services/MarkdownService.php +++ b/packages/framework/src/Services/MarkdownService.php @@ -66,17 +66,7 @@ protected function setupConverter(): void // Determine what dynamic extensions to enable if ($this->canEnablePermalinks()) { - $this->addExtension(HeadingPermalinkExtension::class); - - $this->config = array_merge([ - 'heading_permalink' =>[ - 'id_prefix' => '', - 'fragment_prefix' => '', - 'symbol' => '#', - 'insert' => 'after', - 'min_heading_level' => 2, - ], - ], $this->config); + $this->configurePermalinksExtension(); } if ($this->canEnableTorchlight()) { @@ -84,13 +74,7 @@ protected function setupConverter(): void } if (config('markdown.allow_html', false)) { - $this->addExtension(DisallowedRawHtmlExtension::class); - - $this->config = array_merge([ - 'disallowed_raw_html' => [ - 'disallowed_tags' => [], - ], - ], $this->config); + $this->enableAllHtmlElements(); } // Add any custom extensions defined in config @@ -217,4 +201,30 @@ protected function injectTorchlightAttribution(): string 'Syntax highlighted by torchlight.dev' )); } + + protected function configurePermalinksExtension(): void + { + $this->addExtension(HeadingPermalinkExtension::class); + + $this->config = array_merge([ + 'heading_permalink' => [ + 'id_prefix' => '', + 'fragment_prefix' => '', + 'symbol' => '#', + 'insert' => 'after', + 'min_heading_level' => 2, + ], + ], $this->config); + } + + protected function enableAllHtmlElements(): void + { + $this->addExtension(DisallowedRawHtmlExtension::class); + + $this->config = array_merge([ + 'disallowed_raw_html' => [ + 'disallowed_tags' => [], + ], + ], $this->config); + } } From 2bb74059aedf5adbb87c961258be39d3a5c68a76 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Aug 2022 20:21:23 +0200 Subject: [PATCH 21/38] Add more schema documentation --- .../src/Concerns/FrontMatter/Schemas/PageSchema.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php b/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php index 5cb5c52772f..a9e6f7a5ee1 100644 --- a/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php +++ b/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php @@ -13,11 +13,21 @@ trait PageSchema * The title of the page used in the HTML tag, among others. * * @example "Home", "About", "Blog Feed" + * @yamlType string|optional */ public string $title; /** * The settings for how the page should be presented in the navigation menu. + * All array values are optional, as long as the array is not empty. + * + * @yamlType array|optional + * @example ```yaml + * navigation: + * title: "Home" + * hidden: true + * priority: 1 + * ``` */ #[ArrayShape(['title' => 'string', 'hidden' => 'bool', 'priority' => 'int'])] public ?array $navigation = null; @@ -25,7 +35,8 @@ trait PageSchema /** * The canonical URL of the page. * - * @var string|null + * @yamlType array|optional + * @example "https://example.com/about" */ public ?string $canonicalUrl = null; From 255c5d07df71f9c3d350be6b70ecf45977475b23 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:24:16 +0200 Subject: [PATCH 22/38] Add package annotations for schemas --- .../src/Concerns/FrontMatter/Schemas/BlogPostSchema.php | 3 +++ .../Concerns/FrontMatter/Schemas/DocumentationPageSchema.php | 3 +++ .../framework/src/Concerns/FrontMatter/Schemas/PageSchema.php | 3 +++ 3 files changed, 9 insertions(+) diff --git a/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php b/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php index c8264a485ad..93be1a3a702 100644 --- a/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php +++ b/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php @@ -6,6 +6,9 @@ use Hyde\Framework\Models\DateString; use Hyde\Framework\Models\Image; +/** + * @package Hyde\Schemas + */ trait BlogPostSchema { /** @example "My New Post" */ diff --git a/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php b/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php index 8cdb08956b3..678a9e88dd7 100644 --- a/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php +++ b/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php @@ -5,6 +5,9 @@ use Hyde\Framework\Hyde; use Illuminate\Support\Str; +/** + * @package Hyde\Schemas + */ trait DocumentationPageSchema { /** diff --git a/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php b/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php index a9e6f7a5ee1..a7f7457339c 100644 --- a/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php +++ b/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php @@ -7,6 +7,9 @@ use Hyde\Framework\Hyde; use JetBrains\PhpStorm\ArrayShape; +/** + * @package Hyde\Schemas + */ trait PageSchema { /** From e85cb3d60df8d240221f3fc854260bb55e18d2f0 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:25:12 +0200 Subject: [PATCH 23/38] Change return annotation to psalm-return --- packages/framework/src/Services/BuildService.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/framework/src/Services/BuildService.php b/packages/framework/src/Services/BuildService.php index a1de4b34430..31a9cb7c260 100644 --- a/packages/framework/src/Services/BuildService.php +++ b/packages/framework/src/Services/BuildService.php @@ -91,9 +91,7 @@ protected function compilePagesForClass(string $pageClass): void $this->newLine(2); } - /** - * @return \Closure(Route):string - */ + /** @psalm-return \Closure(Route):string */ protected function compileRoute(): \Closure { return function (Route $route) { From 6c747ec799f41a141788d4ca5a800f5a22a26b8e Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:35:10 +0200 Subject: [PATCH 24/38] Conditional does not need to be nested --- .../Actions/Constructors/FindsNavigationDataForPage.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index 55a27d50403..d034813bc6a 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -38,11 +38,11 @@ protected function getNavigationMenuTitle(): string return $this->page->matter('navigation.title'); } - if ($this->page->identifier === 'index') { - if ($this->page instanceof DocumentationPage) { - return config('hyde.navigation.labels.docs', 'Docs'); - } + if ($this->page instanceof DocumentationPage) { + return config('hyde.navigation.labels.docs', 'Docs'); + } + if ($this->page->identifier === 'index') { return config('hyde.navigation.labels.home', 'Home'); } From a4d17084106bdb159b06f4b974086a6d9733c935 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:36:50 +0200 Subject: [PATCH 25/38] Update customization.md --- docs/digging-deeper/customization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/digging-deeper/customization.md b/docs/digging-deeper/customization.md index 48dcf02f855..b90d8ff5693 100644 --- a/docs/digging-deeper/customization.md +++ b/docs/digging-deeper/customization.md @@ -186,7 +186,7 @@ Hyde makes an effort to organize the menu items in a sensible way. Putting your 'order' => [ 'index' => 0, // _pages/index.md (or .blade.php) 'posts' => 10, // _pages/posts.md (or .blade.php) - 'docs' => 100, // _docs/index.md + 'docs/index' => 100, // _docs/index.md ] ] ``` From a4357cced2d571077eca820c2f7fdba2f5ceae18 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:38:27 +0200 Subject: [PATCH 26/38] Update customization.md --- docs/digging-deeper/customization.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/digging-deeper/customization.md b/docs/digging-deeper/customization.md index b90d8ff5693..c76a9e2ce18 100644 --- a/docs/digging-deeper/customization.md +++ b/docs/digging-deeper/customization.md @@ -226,7 +226,9 @@ Simplified, this will then be rendered as follows: #### 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 slug to the blacklist. As you can see, the `404` page has already been filled in for you. Note that we don't specify the page type, since only top level pages are added to the navigation menu. +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 slug to the blacklist. As you can see, the `404` page has already been filled in for you. + +Note that we don't specify the page type, since only top level pages are added to the navigation menu (with the exception of the automatic documentation page link, which can be hidden in the config by using `docs/index`). ```php 'navigation' => [ From 89b9845237044bc318f5e6d11cf86eddc6a923fe Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:39:25 +0200 Subject: [PATCH 27/38] Simplify if with default return value --- .../src/Actions/Constructors/FindsNavigationDataForPage.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index d034813bc6a..408791afe0a 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -46,11 +46,7 @@ protected function getNavigationMenuTitle(): string return config('hyde.navigation.labels.home', 'Home'); } - if ($this->page->matter('title') !== null) { - return $this->page->matter('title'); - } - - return $this->page->title; + return $this->page->matter('title', $this->page->title); } protected function getNavigationMenuVisible(): bool From 88a14c9a244339f46212089af8d4d1eb8ffc0373 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:45:54 +0200 Subject: [PATCH 28/38] The route key should be used in the config --- docs/digging-deeper/customization.md | 6 ++++-- .../src/Actions/Constructors/FindsNavigationDataForPage.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/digging-deeper/customization.md b/docs/digging-deeper/customization.md index c76a9e2ce18..8d3ff2681fd 100644 --- a/docs/digging-deeper/customization.md +++ b/docs/digging-deeper/customization.md @@ -251,18 +251,20 @@ navigation: Hyde makes a few attempts to find a suitable label for the navigation menu items to automatically create helpful titles. You can override the title using the `navigation.title` front matter property. -From the Hyde config you can also override the title of the documentation label and home page link using the following options: +From the Hyde config you can also override the title of navigation links using the by mapping the slug (relative to the site root) to a title. Note that the front matter property will take precedence over the config property. + ```php // filepath config/hyde.php 'navigation' => [ 'labels' => [ - 'docs' => 'Documentation', 'index' => 'Start', + 'docs/index' => 'Documentation', ] ] ``` + ## Blade Views Hyde uses the Laravel templating system called Blade. Most parts have been extracted into components to be customized easily. diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index 408791afe0a..c985790dbde 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -39,11 +39,11 @@ protected function getNavigationMenuTitle(): string } if ($this->page instanceof DocumentationPage) { - return config('hyde.navigation.labels.docs', 'Docs'); + return config('hyde.navigation.labels.docs/index', 'Docs'); } if ($this->page->identifier === 'index') { - return config('hyde.navigation.labels.home', 'Home'); + return config('hyde.navigation.labels.index', 'Home'); } return $this->page->matter('title', $this->page->title); From 709cc64f730163affe5f934402530673565b9be9 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:47:54 +0200 Subject: [PATCH 29/38] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e73347c2e8d..4d277dd6697 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -49,7 +49,7 @@ The RoutingService class remains for compatibility with existing code, but now o Prior to this release, the navigation menu priorities were based on the page slug. This has been changed to the route key. A route key in Hyde is in short the compiled page's path, relative to the site's root. For example, `_site/foo/bar.html` has the route key `foo/bar`. -This change is breaking as it requires the configuration to be updated. However, this is really easy. Just change `docs` to `docs/index` in the `config/hyde.php` file. +This change is breaking as the order of navigation items may be changed unless the configuration is updated. However, this is really easy. Just change `docs` to `docs/index` in the `config/hyde.php` file. ```diff 'navigation' => [ @@ -63,3 +63,5 @@ This change is breaking as it requires the configuration to be updated. However, ``` If you have used the config to hide the documentation page from the navigation menu, you also need to use the route key by changing `'exclude' => ['docs']` to `'exclude' => ['docs/index']`. +The same goes if you have used the config to change the navigation titles for the home and documentation pages. + From 406b9b3f4895999de568184e6a298fa21228cf18 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:48:55 +0200 Subject: [PATCH 30/38] Add configuration stubs from the documentation --- config/hyde.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/hyde.php b/config/hyde.php index 2acba7c8e80..e53a7cad2a2 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -132,6 +132,12 @@ 'docs/index' => 100, ], + // In case you want to customize the labels for the menu items, you can do so here. + 'labels' => [ + // 'index' => 'Start', + // 'docs/index' => 'Documentation', + ], + // These are the pages that should not show up in the navigation menu. 'exclude' => [ '404', From 769ee8b46fa76759fbf2adf969f028b9ff29090a Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:49:49 +0200 Subject: [PATCH 31/38] Synchronize the configuration files --- packages/framework/config/hyde.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index 6d4a9a08fcb..e53a7cad2a2 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -125,10 +125,17 @@ 'navigation' => [ // This configuration sets the priorities used to determine the order of the menu. // The default values have been added below for reference and easy editing. + // The array key should match the page's route key (slug). 'order' => [ 'index' => 0, 'posts' => 10, - 'docs' => 100, + 'docs/index' => 100, + ], + + // In case you want to customize the labels for the menu items, you can do so here. + 'labels' => [ + // 'index' => 'Start', + // 'docs/index' => 'Documentation', ], // These are the pages that should not show up in the navigation menu. From fd6af63997682b481e80f8510bb6013c749cb5a0 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 20:53:35 +0200 Subject: [PATCH 32/38] Add section "Front Matter or Configuration Files?" --- docs/digging-deeper/customization.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/digging-deeper/customization.md b/docs/digging-deeper/customization.md index 8d3ff2681fd..5bfd90ea3c9 100644 --- a/docs/digging-deeper/customization.md +++ b/docs/digging-deeper/customization.md @@ -14,6 +14,10 @@ When referencing configuration options, we often use "dot notation" to specify t If you want to reference these configuration options in your Blade views, or other integrations, please take a look at the [Laravel Documentation](https://laravel.com/docs/9.x/configuration). +### Front Matter or Configuration Files? + +In some cases, the same options can be set in the front matter of a page or in a configuration file. Both ways are always documented, and it's up to you to choose which one you prefer. Note that in most cases, if a setting is set in both the front matter and the configuration file, the front matter setting will take precedence. + ## Configuration Files Overview There are a few configuration files available in the `config` directory. All options are documented, so feel free to look through the files and get familiar with the options available to you. From 5d9c193b89e3ddee78a22377902f4a74c50d923b Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 21:02:03 +0200 Subject: [PATCH 33/38] Replace default value with null coalesce --- .../src/Actions/Constructors/FindsNavigationDataForPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index c985790dbde..b617f13e986 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -46,7 +46,7 @@ protected function getNavigationMenuTitle(): string return config('hyde.navigation.labels.index', 'Home'); } - return $this->page->matter('title', $this->page->title); + return $this->page->matter('title') ?? $this->page->title; } protected function getNavigationMenuVisible(): bool From b8e8a85af892c42c57998831470340c34eb10be3 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 21:03:12 +0200 Subject: [PATCH 34/38] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4d277dd6697..73fb740c634 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -26,6 +26,7 @@ The RoutingService class remains for compatibility with existing code, but now o - An exception is now thrown when attempting to get the path to an Image without a defined source path or URI - internal: The HydeKernel is now stored as a singleton within the kernel class, instead of the service container - internal: Refactor commands with shared code to extend new abstract base class +- internal: A large part of the codebase has been refactored and cleaned up while making an effort to maintain compatibility with existing code ### Deprecated - Deprecated interface RoutingServiceContract @@ -64,4 +65,3 @@ This change is breaking as the order of navigation items may be changed unless t If you have used the config to hide the documentation page from the navigation menu, you also need to use the route key by changing `'exclude' => ['docs']` to `'exclude' => ['docs/index']`. The same goes if you have used the config to change the navigation titles for the home and documentation pages. - From aab747ac53f4f1a20e06fb0995838c6edfd92bde Mon Sep 17 00:00:00 2001 From: StyleCI Bot <bot@styleci.io> Date: Thu, 11 Aug 2022 19:03:28 +0000 Subject: [PATCH 35/38] Apply fixes from StyleCI --- .../src/Concerns/FrontMatter/Schemas/BlogPostSchema.php | 3 --- .../Concerns/FrontMatter/Schemas/DocumentationPageSchema.php | 3 --- .../src/Concerns/FrontMatter/Schemas/PageSchema.php | 5 ++--- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php b/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php index 93be1a3a702..c8264a485ad 100644 --- a/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php +++ b/packages/framework/src/Concerns/FrontMatter/Schemas/BlogPostSchema.php @@ -6,9 +6,6 @@ use Hyde\Framework\Models\DateString; use Hyde\Framework\Models\Image; -/** - * @package Hyde\Schemas - */ trait BlogPostSchema { /** @example "My New Post" */ diff --git a/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php b/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php index 678a9e88dd7..8cdb08956b3 100644 --- a/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php +++ b/packages/framework/src/Concerns/FrontMatter/Schemas/DocumentationPageSchema.php @@ -5,9 +5,6 @@ use Hyde\Framework\Hyde; use Illuminate\Support\Str; -/** - * @package Hyde\Schemas - */ trait DocumentationPageSchema { /** diff --git a/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php b/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php index a7f7457339c..172f434965c 100644 --- a/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php +++ b/packages/framework/src/Concerns/FrontMatter/Schemas/PageSchema.php @@ -7,9 +7,6 @@ use Hyde\Framework\Hyde; use JetBrains\PhpStorm\ArrayShape; -/** - * @package Hyde\Schemas - */ trait PageSchema { /** @@ -25,6 +22,7 @@ trait PageSchema * All array values are optional, as long as the array is not empty. * * @yamlType array|optional + * * @example ```yaml * navigation: * title: "Home" @@ -39,6 +37,7 @@ trait PageSchema * The canonical URL of the page. * * @yamlType array|optional + * * @example "https://example.com/about" */ public ?string $canonicalUrl = null; From 1b5b72c7e6bae9c6267e3e9dcf2f4f4bc8bad47a Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 21:10:51 +0200 Subject: [PATCH 36/38] Use getter to get canonical url --- packages/framework/src/Models/Metadata/Metadata.php | 2 +- packages/framework/tests/Feature/MetadataTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Models/Metadata/Metadata.php b/packages/framework/src/Models/Metadata/Metadata.php index 7ad3fbbb6c2..111b98c1f75 100644 --- a/packages/framework/src/Models/Metadata/Metadata.php +++ b/packages/framework/src/Models/Metadata/Metadata.php @@ -77,7 +77,7 @@ protected function generate(): void } if ($this->page->has('canonicalUrl')) { - $this->add(Meta::link('canonical', $this->page->canonicalUrl)); + $this->add(Meta::link('canonical', $this->page->get('canonicalUrl'))); } if ($this->page->has('title')) { diff --git a/packages/framework/tests/Feature/MetadataTest.php b/packages/framework/tests/Feature/MetadataTest.php index e857bb2f536..ad9bc620193 100644 --- a/packages/framework/tests/Feature/MetadataTest.php +++ b/packages/framework/tests/Feature/MetadataTest.php @@ -385,6 +385,12 @@ public function test_does_not_add_url_property_when_canonical_url_is_not_set_in_ $this->assertPageDoesNotHaveMetadata($page, '<meta property="og:url" content="example.html">'); } + public function test_does_not_add_url_property_when_canonical_url_is_null() + { + $page = MarkdownPost::make(matter: ['canonicalUrl' => null]); + $this->assertPageDoesNotHaveMetadata($page, '<meta property="og:url" content="example.html">'); + } + public function test_adds_title_property_when_title_is_set_in_post() { $page = MarkdownPost::make(matter: ['title' => 'My Title']); From 1866476c9f0713e7f99619de17dd08c28078d4e2 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 21:27:24 +0200 Subject: [PATCH 37/38] Revert "Conditional does not need to be nested" This reverts commit 6c747ec799f41a141788d4ca5a800f5a22a26b8e as the label is also used in the sidebar --- .../Constructors/FindsNavigationDataForPage.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index b617f13e986..5d9cddb2929 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -38,12 +38,12 @@ protected function getNavigationMenuTitle(): string return $this->page->matter('navigation.title'); } - if ($this->page instanceof DocumentationPage) { - return config('hyde.navigation.labels.docs/index', 'Docs'); - } - if ($this->page->identifier === 'index') { - return config('hyde.navigation.labels.index', 'Home'); + if ($this->page instanceof DocumentationPage) { + return config('hyde.navigation.labels.docs', 'Docs'); + } + + return config('hyde.navigation.labels.home', 'Home'); } return $this->page->matter('title') ?? $this->page->title; From e906909a039d26807ffbb88ddcdc252186762cf6 Mon Sep 17 00:00:00 2001 From: Caen De Silva <caen@desilva.se> Date: Thu, 11 Aug 2022 21:28:56 +0200 Subject: [PATCH 38/38] Add PHPDocs --- .../src/Actions/Constructors/FindsNavigationDataForPage.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php index 5d9cddb2929..3ecf3e2c634 100644 --- a/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php +++ b/packages/framework/src/Actions/Constructors/FindsNavigationDataForPage.php @@ -8,6 +8,8 @@ use JetBrains\PhpStorm\ArrayShape; /** + * Finds the appropriate navigation data for a page. + * * @see \Hyde\Framework\Testing\Feature\AbstractPageTest */ class FindsNavigationDataForPage @@ -32,6 +34,9 @@ protected function getData(): array ]; } + /** + * Note that this also affects the documentation sidebar titles. + */ protected function getNavigationMenuTitle(): string { if ($this->page->matter('navigation.title') !== null) {