Skip to content

Commit

Permalink
Merge pull request #2032 from hydephp/natural-language-documentation-…
Browse files Browse the repository at this point in the history
…search-page-title

[2.x] Natural language documentation search page header generation
  • Loading branch information
caendesilva authored Nov 16, 2024
2 parents b2a3fb9 + db01c60 commit c5886eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ This serves two purposes:
- The `Markdown::render()` method will now always render Markdown using the custom HydePHP Markdown service (thus getting smart features like our Markdown processors) in https://github.com/hydephp/develop/pull/1900
- Improved how the `MarkdownService` class is accessed, by binding it into the service container, in https://github.com/hydephp/develop/pull/1922
- Improved the media asset transfer build task to have better output in https://github.com/hydephp/develop/pull/1904
- The full page documentation search now generates it's heading using smarter natural language processing based on the configured sidebar header in https://github.com/hydephp/develop/pull/2032
- **Many MediaFile related helpers have been changed or completely rewritten** to provide a simplified API for interacting with media files.
- **Note:** For most end users, the changes will have minimal direct impact, but if you have custom code that interacts with media files, you may need to update it.
- The `Asset` facade has been restructured to be more scoped and easier to use, splitting out a separate `HydeFront` facade and inlining the `AssetService` class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
@extends('hyde::layouts.docs')
@section('content')
<h1>Search the documentation site</h1>
@php
$title = Config::getString('docs.sidebar.header', 'Documentation');
$searchTitle = str_ends_with(strtolower($title), ' docs')
? 'Search the ' . substr($title, 0, -5) . ' Documentation'
: 'Search ' . $title;
@endphp
<h1>{{ $searchTitle }}</h1>
<style>#search-menu-button, .edit-page-link {
display: none !important;
}
Expand Down
20 changes: 19 additions & 1 deletion packages/framework/tests/Feature/DocumentationSearchPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testCanRenderSearchPage()
$page = new DocumentationSearchPage();

Hyde::shareViewData($page);
$this->assertStringContainsString('<h1>Search the documentation site</h1>', $page->compile());
$this->assertStringContainsString('<h1>Search the HydePHP Documentation</h1>', $page->compile());
}

public function testRenderedSearchPageUsesDocumentationPageLayout()
Expand All @@ -106,4 +106,22 @@ public function testRenderedSearchPageDoesNotUseSemanticDocumentationMarkup()
$this->assertStringNotContainsString('<section id="document-main-content"', $html);
$this->assertStringNotContainsString('<footer id="document-footer"', $html);
}

public function testRenderedSearchPageUsesCustomSidebarHeader()
{
config(['docs.sidebar.header' => 'My Project']);
$page = new DocumentationSearchPage();

Hyde::shareViewData($page);
$this->assertStringContainsString('<h1>Search My Project</h1>', $page->compile());
}

public function testRenderedSearchPageExpandsDocsInSidebarHeader()
{
config(['docs.sidebar.header' => 'Custom Docs']);
$page = new DocumentationSearchPage();

Hyde::shareViewData($page);
$this->assertStringContainsString('<h1>Search the Custom Documentation</h1>', $page->compile());
}
}

0 comments on commit c5886eb

Please sign in to comment.