Skip to content

Commit

Permalink
Merge pull request #412 from hydephp/410-search-index-generator-break…
Browse files Browse the repository at this point in the history
…s-when-storing-documentation-page-source-files-in-subdirectories

Fix #410: Search index generator breaks when storing documentation page source files in subdirectories hydephp/develop@0ea94ec
  • Loading branch information
github-actions committed Aug 11, 2022
1 parent 7ac96b4 commit cd697fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Actions/GeneratesDocumentationSearchIndexFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public function generate(): static
public function generatePageObject(DocumentationPage $page): object
{
return (object) [
'slug' => $page->identifier,
'slug' => basename($page->identifier),
'title' => $page->title,
'content' => trim($this->getSearchContentForDocument($page)),
'destination' => $this->getDestinationForSlug($page->identifier),
'destination' => $this->getDestinationForSlug(basename($page->identifier)),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,15 @@ public function test_excluded_pages_are_not_present_in_the_search_index()

unlink(Hyde::path('_docs/excluded.md'));
}

public function test_nested_source_files_do_not_retain_directory_name_in_search_index()
{
mkdir(Hyde::path('_docs/foo'));
touch(Hyde::path('_docs/foo/bar.md'));

$this->assertStringNotContainsString('foo', (new Action())->generate()->getJson());

unlink(Hyde::path('_docs/foo/bar.md'));
rmdir(Hyde::path('_docs/foo'));
}
}

0 comments on commit cd697fa

Please sign in to comment.