Skip to content

Commit

Permalink
Inline simplified helper
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 18, 2023
1 parent be553d7 commit 83cfa5a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/HydeSearch.min.js" defer></script>
<script>
window.addEventListener('load', function () {
const searchIndexLocation = '{{ Hyde::relativeLink(\Hyde\Framework\Features\Documentation\DocumentationSearchIndex::routeKey()) }}';
const searchIndexLocation = '{{ Hyde::relativeLink(\Hyde\Framework\Features\Documentation\DocumentationSearchIndex::outputPath()) }}';
const Search = new HydeSearch(searchIndexLocation);
Search.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function formatDestination(string $slug): string

protected function getPath(): string
{
return Hyde::sitePath(DocumentationSearchIndex::routeKey());
return Hyde::sitePath(DocumentationSearchIndex::outputPath());
}

protected function getPagesToExcludeFromSearch(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DocumentationSearchIndex extends InMemoryPage
*/
public function __construct()
{
parent::__construct(static::routeKey(), [
parent::__construct(DocumentationSearchIndex::outputPath(), [
'navigation' => ['hidden' => true],
]);
}
Expand All @@ -33,9 +33,4 @@ public static function outputPath(string $identifier = ''): string
{
return RouteKey::fromPage(DocumentationPage::class, 'search').'.json';
}

public static function routeKey(): string
{
return static::outputPath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ public function testRouteKeyIsSetToConfiguredDocumentationOutputDirectory()
$this->assertSame('foo/search.json', $page->routeKey);
}

public function testStaticRouteKeyHelper()
public function testStaticOutputPathHelper()
{
$this->assertSame('docs/search.json', DocumentationSearchIndex::routeKey());
$this->assertSame('docs/search.json', DocumentationSearchIndex::outputPath());
}

public function testStaticRouteKeyHelperWithCustomOutputDirectory()
public function testStaticOutputPathHelperWithCustomOutputDirectory()
{
DocumentationPage::setOutputDirectory('foo');
$this->assertSame('foo/search.json', DocumentationSearchIndex::routeKey());
$this->assertSame('foo/search.json', DocumentationSearchIndex::outputPath());
}

public function testStaticRouteKeyHelperWithRootOutputDirectory()
public function testStaticOutputPathHelperWithRootOutputDirectory()
{
DocumentationPage::setOutputDirectory('');
$this->assertSame('search.json', DocumentationSearchIndex::routeKey());
$this->assertSame('search.json', DocumentationSearchIndex::outputPath());
}
}

0 comments on commit 83cfa5a

Please sign in to comment.