1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Hyde\Framework\Models\Pages; |
4
|
|
|
|
5
|
|
|
use Hyde\Framework\Concerns\HasTableOfContents; |
6
|
|
|
use Hyde\Framework\Contracts\AbstractMarkdownPage; |
7
|
|
|
use Hyde\Framework\Contracts\RouteContract; |
8
|
|
|
use Hyde\Framework\Models\Route; |
9
|
|
|
|
10
|
|
|
class DocumentationPage extends AbstractMarkdownPage |
11
|
|
|
{ |
12
|
|
|
use HasTableOfContents; |
13
|
|
|
|
14
|
|
|
public static string $sourceDirectory = '_docs'; |
15
|
|
|
public static string $outputDirectory = 'docs'; |
16
|
|
|
public static string $template = 'hyde::layouts/docs'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The sidebar category group, if any. |
20
|
|
|
*/ |
21
|
|
|
public ?string $category; |
22
|
|
|
|
23
|
|
|
public function __construct(array $matter = [], string $body = '', string $title = '', string $slug = '') |
24
|
|
|
{ |
25
|
|
|
parent::__construct($matter, $body, $title, $slug); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** @inheritDoc */ |
29
|
|
|
public function getCurrentPagePath(): string |
30
|
|
|
{ |
31
|
|
|
return trim(static::getOutputDirectory().'/'.basename($this->slug), '/'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** @internal */ |
35
|
|
|
public function getOnlineSourcePath(): string|false |
36
|
|
|
{ |
37
|
|
|
if (config('docs.source_file_location_base') === null) { |
38
|
|
|
return false; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return trim(config('docs.source_file_location_base'), '/').'/'.$this->slug.'.md'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public static function home(): ?RouteContract |
45
|
|
|
{ |
46
|
|
|
return Route::exists('docs/index') ? Route::get('docs/index') : null; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public static function hasTableOfContents(): bool |
50
|
|
|
{ |
51
|
|
|
return config('docs.table_of_contents.enabled', true); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|