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

[2.x] Natural language documentation search page header generation #2032

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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());
}
}