Skip to content

Commit

Permalink
Parse the documentation pages using the fileservice
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 17, 2022
1 parent 9d1b206 commit 041bf98
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/DocumentationPageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
namespace Hyde\Framework;

use Hyde\Framework\Models\DocumentationPage;
use Hyde\Framework\Services\MarkdownFileService;

class DocumentationPageParser extends AbstractPageParser
{
protected string $pageModel = DocumentationPage::class;
protected string $slug;

public string $body;
public string $title;
public string $body;

public function execute(): void
{
$stream = file_get_contents(Hyde::path("_docs/$this->slug.md"));

$this->title = $this->findTitleTag($stream) ??
Hyde::titleFromSlug($this->slug);
$document = (new MarkdownFileService(
Hyde::path("_docs/$this->slug.md")
))->get();

if (isset($document->matter['title'])) {
$this->title = $document->matter['title'];
} else {
$this->title = $this->findTitleTag($document->body) ??
Hyde::titleFromSlug($this->slug);
}

$this->body = $stream;
$this->body = $document->body;
}

/**
Expand Down

0 comments on commit 041bf98

Please sign in to comment.