Skip to content

Commit 2d12591

Browse files
authoredJun 23, 2022
Merge pull request #96 from hydephp/94-bug-hydedocsindexpath-checks-the-hard-coded-source-directory
Fix bug #94: Hyde::docsIndexPath() checks the hard-coded source directory
2 parents 99ad45f + b5be479 commit 2d12591

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
 

‎packages/framework/src/Concerns/Internal/FileHelpers.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Hyde\Framework\Concerns\Internal;
44

5+
use Hyde\Framework\Models\DocumentationPage;
6+
57
/**
68
* Offloads file helper methods for the Hyde Facade.
79
*
@@ -31,11 +33,11 @@ public static function getDocumentationOutputDirectory(): string
3133
*/
3234
public static function docsIndexPath(): string|false
3335
{
34-
if (file_exists(static::path('_docs/index.md'))) {
36+
if (file_exists(static::path(DocumentationPage::$sourceDirectory.'/index.md'))) {
3537
return trim(static::pageLink(static::getDocumentationOutputDirectory().'/index.html'), '/');
3638
}
3739

38-
if (file_exists(static::path('_docs/readme.md'))) {
40+
if (file_exists(static::path(DocumentationPage::$sourceDirectory.'/readme.md'))) {
3941
return trim(static::pageLink(static::getDocumentationOutputDirectory().'/readme.html'), '/');
4042
}
4143

‎packages/framework/tests/Feature/HydeDocsIndexPathTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Hyde\Framework\Testing\Feature;
44

55
use Hyde\Framework\Hyde;
6+
use Hyde\Framework\Models\DocumentationPage;
67
use Hyde\Testing\TestCase;
78

89
class HydeDocsIndexPathTest extends TestCase
@@ -45,6 +46,18 @@ public function test_returns_index_if_only_index_exist()
4546
$this->assertEquals('docs/index.html', Hyde::docsIndexPath());
4647
}
4748

49+
public function test_helper_can_find_index_path_when_custom_docs_directory_is_used()
50+
{
51+
mkdir(Hyde::path('foo'));
52+
file_put_contents(Hyde::path('foo/index.md'), '');
53+
54+
DocumentationPage::$sourceDirectory = 'foo';
55+
$this->assertEquals('docs/index.html', Hyde::docsIndexPath());
56+
57+
unlink(Hyde::path('foo/index.md'));
58+
rmdir(Hyde::path('foo'));
59+
}
60+
4861
private function setReadme()
4962
{
5063
file_put_contents(Hyde::path('_docs/readme.md'), '');

0 commit comments

Comments
 (0)
Please sign in to comment.