From 91829ea601a9e0ce550327da8321c842b0e5aec4 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 13 Feb 2024 15:11:49 +0100 Subject: [PATCH 1/5] Only render semantic documentation article markup when truthy --- .../docs/documentation-article.blade.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/framework/resources/views/components/docs/documentation-article.blade.php b/packages/framework/resources/views/components/docs/documentation-article.blade.php index 328f370982d..56c71641771 100644 --- a/packages/framework/resources/views/components/docs/documentation-article.blade.php +++ b/packages/framework/resources/views/components/docs/documentation-article.blade.php @@ -5,16 +5,18 @@
$article->hasTorchlight()])> + 'torchlight-enabled' => $article && $article->hasTorchlight()])> @yield('content') -
- {{ $article->renderHeader() }} -
-
- {{ $article->renderBody() }} -
-
- {{ $article->renderFooter() }} -
+ @if ($article) +
+ {{ $article->renderHeader() }} +
+
+ {{ $article->renderBody() }} +
+
+ {{ $article->renderFooter() }} +
+ @endif
\ No newline at end of file From e1f010c129bf75f97d22754dbb124e138c5e7f37 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 13 Feb 2024 15:12:14 +0100 Subject: [PATCH 2/5] Update documentation search page to set article to false --- .../Features/Documentation/DocumentationSearchPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index 7db4a83ca97..e31ae29d1a1 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -39,7 +39,7 @@ public function __construct() parent::__construct(static::routeKey(), [ 'title' => 'Search', 'navigation' => ['hidden' => true], - 'article' => $this->makeArticle(), + 'article' => false, ], view: 'hyde::pages.documentation-search'); } From 7df529e085a02bce6b1425e3a5dc9c98c60177e6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 13 Feb 2024 15:12:24 +0100 Subject: [PATCH 3/5] Remove now unused internal experimental method --- .../Features/Documentation/DocumentationSearchPage.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index e31ae29d1a1..61f4b2e8930 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -59,10 +59,4 @@ protected static function anotherSearchPageExists(): bool // we need to check the page collection directly, instead of the route collection. return Hyde::pages()->first(fn (HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null; } - - /** @experimental Fixes type issue {@see https://github.com/hydephp/develop/commit/37f7046251b8c0514b8d8ef821de4ef3d35bbac8#commitcomment-135026537} */ - protected function makeArticle(): SemanticDocumentationArticle - { - return SemanticDocumentationArticle::make(new DocumentationPage()); - } } From 9febd5dd0a12bf4b62873d36c0a16431711e0d76 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 13 Feb 2024 15:20:19 +0100 Subject: [PATCH 4/5] Update search page test to test the rendered HTML --- .../Feature/DocumentationSearchPageTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/framework/tests/Feature/DocumentationSearchPageTest.php b/packages/framework/tests/Feature/DocumentationSearchPageTest.php index e7a2adc4dc3..2a237064dbc 100644 --- a/packages/framework/tests/Feature/DocumentationSearchPageTest.php +++ b/packages/framework/tests/Feature/DocumentationSearchPageTest.php @@ -76,4 +76,34 @@ public function testStaticRouteKeyHelperWithRootOutputDirectory() DocumentationPage::setOutputDirectory(''); $this->assertSame('search', DocumentationSearchPage::routeKey()); } + + public function testCanRenderSearchPage() + { + $page = new DocumentationSearchPage(); + + Hyde::shareViewData($page); + $this->assertStringContainsString('

Search the documentation site

', $page->compile()); + } + + public function testRenderedSearchPageUsesDocumentationPageLayout() + { + $page = new DocumentationSearchPage(); + + Hyde::shareViewData($page); + $html = $page->compile(); + + $this->assertStringContainsString('compile(); + + $this->assertStringNotContainsString('
assertStringNotContainsString('
assertStringNotContainsString('