@@ -68,29 +68,29 @@ protected function parseMarkdownPage(string $pageClass): AbstractMarkdownPage
68
68
69
69
protected function constructDynamicData (): void
70
70
{
71
- $ this ->page ->title = $ this ->findTitleForPage ( );
71
+ $ this ->page ->title = static :: findTitleForPage ( $ this ->page , $ this -> slug );
72
72
73
73
if ($ this ->page instanceof DocumentationPage) {
74
- $ this ->page ->category = $ this ->getDocumentationPageCategory ( );
74
+ $ this ->page ->category = static :: getDocumentationPageCategory ( $ this ->slug , $ this -> page );
75
75
}
76
76
}
77
77
78
- protected function findTitleForPage (): string
78
+ public static function findTitleForPage ($ page , $ slug ): string
79
79
{
80
- if ($ this -> page instanceof BladePage) {
81
- return Hyde::makeTitle ($ this -> slug );
80
+ if ($ page instanceof BladePage) {
81
+ return Hyde::makeTitle ($ slug );
82
82
}
83
83
84
- if ($ this -> page ->matter ('title ' )) {
85
- return $ this -> page ->matter ('title ' );
84
+ if ($ page ->matter ('title ' )) {
85
+ return $ page ->matter ('title ' );
86
86
}
87
87
88
- return $ this -> findTitleFromMarkdownHeadings () ?? Hyde::makeTitle ($ this -> slug );
88
+ return static :: findTitleFromMarkdownHeadings ($ page ) ?? Hyde::makeTitle ($ slug );
89
89
}
90
90
91
- protected function findTitleFromMarkdownHeadings (): ?string
91
+ public static function findTitleFromMarkdownHeadings ($ page ): ?string
92
92
{
93
- foreach ($ this -> page ->markdown ()->toArray () as $ line ) {
93
+ foreach ($ page ->markdown ()->toArray () as $ line ) {
94
94
if (str_starts_with ($ line , '# ' )) {
95
95
return trim (substr ($ line , 2 ), ' ' );
96
96
}
@@ -99,15 +99,15 @@ protected function findTitleFromMarkdownHeadings(): ?string
99
99
return null ;
100
100
}
101
101
102
- protected function getDocumentationPageCategory (): ?string
102
+ public static function getDocumentationPageCategory ($ slug , $ page ): ?string
103
103
{
104
104
// If the documentation page is in a subdirectory,
105
105
// then we can use that as the category name.
106
106
// Otherwise, we look in the front matter.
107
107
108
- return str_contains ($ this -> slug , '/ ' )
109
- ? Str::before ($ this -> slug , '/ ' )
110
- : $ this -> page ->matter ('category ' );
108
+ return str_contains ($ slug , '/ ' )
109
+ ? Str::before ($ slug , '/ ' )
110
+ : $ page ->matter ('category ' );
111
111
}
112
112
113
113
public function get (): PageContract
0 commit comments