Skip to content

Commit 75d1fae

Browse files
authored
Merge pull request #4 from billmn/docs-controller-improvements
Some DocsController improvements
2 parents 22c280c + c827934 commit 75d1fae

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

app/Http/Controllers/DocsController.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,24 @@ class DocsController extends Controller
2424
*/
2525
public function __invoke(Documentation $docs, string $page = null)
2626
{
27+
$defaultVersion = config('site.defaultVersion');
28+
2729
if ($page === null) {
2830
return redirect()->route('docs', [self::DEFAULT_PAGE]);
2931
}
3032

31-
if (! $docs->exists(config('site.defaultVersion'), $page) || in_array($page, self::EXCLUDED)) {
33+
if (! $docs->exists($defaultVersion, $page) || in_array($page, self::EXCLUDED)) {
3234
abort(404);
3335
}
3436

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;
4138

42-
$parsedown = new Parsedown();
43-
$body = $parsedown->text($markdown);
39+
$index = $parsedown->text($docs->getIndex($defaultVersion));
40+
$contents = YamlFrontMatter::parse($docs->get($defaultVersion, $page));
4441

42+
$body = $parsedown->text($contents->body());
43+
$matter = $contents->matter();
4544

46-
return view('docs', compact('body', 'matter', 'markdown', 'page', 'index'));
45+
return view('docs', compact('body', 'matter', 'page', 'index'));
4746
}
4847
}

app/Support/Documentation.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ protected function path(string $version, string $file): string
4444
{
4545
return resource_path("docs/{$version}/{$file}");
4646
}
47-
4847
}

0 commit comments

Comments
 (0)