File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ public function generatePageEntry(DocumentationPage $page): array
7474 'slug ' => basename ($ page ->identifier ),
7575 'title ' => $ page ->title ,
7676 'content ' => trim ($ this ->getSearchContentForDocument ($ page )),
77- 'destination ' => $ this ->getDestinationForSlug (basename ($ page ->identifier )),
77+ 'destination ' => $ this ->formatDestination (basename ($ page ->identifier )),
7878 ];
7979 }
8080
@@ -92,13 +92,13 @@ protected function getSearchContentForDocument(DocumentationPage $page): string
9292 return (new ConvertsMarkdownToPlainText ($ page ->markdown ->body ()))->execute ();
9393 }
9494
95- public function getDestinationForSlug (string $ slug ): string
95+ protected function formatDestination (string $ slug ): string
9696 {
9797 if (config ('site.pretty_urls ' , false ) === true ) {
98- return $ slug !== 'index ' ? $ slug : '' ;
98+ return $ slug === 'index ' ? '' : $ slug ;
9999 }
100100
101- return $ slug .' . html' ;
101+ return " $ slug.html " ;
102102 }
103103
104104 public static function getFilePath (): string
Original file line number Diff line number Diff line change @@ -93,18 +93,20 @@ public function test_it_strips_markdown()
9393 public function test_get_destination_for_slug_returns_empty_string_for_index_when_pretty_url_is_enabled ()
9494 {
9595 config (['site.pretty_urls ' => true ]);
96+ $ this ->file ('_docs/index.md ' );
9697
9798 $ this ->assertSame ('' ,
98- (new DocumentationSearchService ())->getDestinationForSlug ( ' index ' )
99+ (new DocumentationSearchService ())->run ()-> searchIndex -> toArray ()[ 0 ][ ' destination ' ]
99100 );
100101 }
101102
102103 public function test_get_destination_for_slug_returns_pretty_url_when_enabled ()
103104 {
104105 config (['site.pretty_urls ' => true ]);
106+ $ this ->file ('_docs/foo.md ' );
105107
106108 $ this ->assertSame ('foo ' ,
107- (new DocumentationSearchService ())->getDestinationForSlug ( ' foo ' )
109+ (new DocumentationSearchService ())->run ()-> searchIndex -> toArray ()[ 0 ][ ' destination ' ]
108110 );
109111 }
110112
You can’t perform that action at this time.
0 commit comments