/** * Show a documentation page. * * @param string $doc * @param string|null $version * @param string|null $page * @return \Illuminate\Http\Response */ public function show($doc, $version = null, $page = null) { if (is_null($version)) { $version = $this->docs->getDefaultVersion($doc); if (is_null($version)) { abort(404); } return redirect()->route('show', [$doc, $version]); } if (is_null($page)) { $page = $this->docs->getDefaultPage($doc, 'installation'); } $content = $this->docs->getContent($doc, $version, $page); if (is_null($content)) { abort(404); } $title = (new Crawler($content))->filterXPath('//h1'); $title = count($title) ? $title->text() : null; return view('show', ['toc' => $this->docs->getToc($doc, $version), 'title' => $title, 'content' => $content, 'currentDoc' => $this->docs->all()[$doc], 'currentVersion' => $version, 'docs' => $this->docs->all(), 'versions' => $this->docs->getVersions($doc), 'page' => $page]); }