Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 14, 2023
1 parent b021766 commit 23c5ae7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Hyde\Pages\DocumentationPage;
use Illuminate\Support\Collection;

use Hyde\Framework\Features\Documentation\DocumentationSearchIndex;
use function tap;
use function basename;
use function in_array;
Expand Down Expand Up @@ -55,14 +56,7 @@ public static function generate(): string
/** @experimental May be moved to a DocumentationSearch class */
public static function makePage(): InMemoryPage
{
return tap(new InMemoryPage('search.json', ['navigation' => ['hidden' => true]]), function (InMemoryPage $page): void {
$page->macro('compile', function (): string {
return GeneratesDocumentationSearchIndex::generate();
});
$page->macro('getOutputPath', function (): string {
return DocumentationPage::outputDirectory().'/search.json';
});
});
return DocumentationSearchIndex::make();
}

protected function __construct()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Hyde\Framework\Features\Documentation;

use Hyde\Hyde;
use Hyde\Facades\Config;
use Hyde\Pages\InMemoryPage;
use Hyde\Pages\DocumentationPage;
use Illuminate\Support\Facades\View;
use Hyde\Framework\Actions\StaticPageBuilder;
use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex;

/**
* @internal This page is used to render the search index for the documentation.
*/
class DocumentationSearchIndex extends InMemoryPage
{
/**
* Generate the search page and save it to disk.
*
* @return string The path to the generated file.
*/
public static function generate(): string
{
return StaticPageBuilder::handle(new static());
}

/**
* Create a new DocumentationSearchPage instance.
*/
public function __construct()
{
parent::__construct('search.json', [
'navigation' => ['hidden' => true],
]);
}

public function compile(): string
{
return GeneratesDocumentationSearchIndex::generate();
}

public function getOutputPath(): string
{
return DocumentationPage::outputDirectory().'/search.json';
}
}

0 comments on commit 23c5ae7

Please sign in to comment.