@@ -24,25 +24,24 @@ class DocsController extends Controller
24
24
*/
25
25
public function __invoke (Documentation $ docs , string $ page = null )
26
26
{
27
+ $ defaultVersion = config ('site.defaultVersion ' );
28
+
27
29
if ($ page === null ) {
28
30
return redirect ()->route ('docs ' , [self ::DEFAULT_PAGE ]);
29
31
}
30
32
31
- if (! $ docs ->exists (config ( ' site. defaultVersion' ) , $ page ) || in_array ($ page , self ::EXCLUDED )) {
33
+ if (! $ docs ->exists ($ defaultVersion , $ page ) || in_array ($ page , self ::EXCLUDED )) {
32
34
abort (404 );
33
35
}
34
36
35
- $ index = (new Parsedown ())->text ($ docs ->getIndex (config ('site.defaultVersion ' )));
36
-
37
- $ file = $ docs ->get (config ('site.defaultVersion ' ), $ page );
38
- $ contents = YamlFrontMatter::parse ($ file );
39
- $ matter = $ contents ->matter ();
40
- $ markdown = $ contents ->body ();
37
+ $ parsedown = new Parsedown ;
41
38
42
- $ parsedown = new Parsedown ( );
43
- $ body = $ parsedown -> text ( $ markdown );
39
+ $ index = $ parsedown -> text ( $ docs -> getIndex ( $ defaultVersion ) );
40
+ $ contents = YamlFrontMatter:: parse ( $ docs -> get ( $ defaultVersion , $ page ) );
44
41
42
+ $ body = $ parsedown ->text ($ contents ->body ());
43
+ $ matter = $ contents ->matter ();
45
44
46
- return view ('docs ' , compact ('body ' , 'matter ' , 'markdown ' , ' page ' , 'index ' ));
45
+ return view ('docs ' , compact ('body ' , 'matter ' , 'page ' , 'index ' ));
47
46
}
48
47
}
0 commit comments