Skip to content

Commit

Permalink
Clear page title if currently on default route
Browse files Browse the repository at this point in the history
  • Loading branch information
askvortsov1 committed May 24, 2020
1 parent 5bf2a0a commit cc07abe
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Frontend/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request;

/**
* A view which renders a HTML skeleton for Flarum's frontend app.
Expand Down Expand Up @@ -131,14 +132,20 @@ class Document implements Renderable
*/
protected $forumApiDocument;

/**
* @var Request
*/
protected $request;

/**
* @param Factory $view
* @param array $forumApiDocument
*/
public function __construct(Factory $view, array $forumApiDocument)
public function __construct(Factory $view, array $forumApiDocument, Request $request)
{
$this->view = $view;
$this->forumApiDocument = $forumApiDocument;
$this->request = $request;
}

/**
Expand Down Expand Up @@ -173,7 +180,8 @@ protected function makeView(): View
*/
protected function makeTitle(): string
{
return ($this->title ? $this->title.' - ' : '').Arr::get($this->forumApiDocument, 'data.attributes.title');
$onHomePage = rtrim($this->request->getAttribute('originalUri')->getPath(), '/') === '';
return ($this->title && !$onHomePage ? $this->title.' - ' : '').Arr::get($this->forumApiDocument, 'data.attributes.title');
}

/**
Expand Down

0 comments on commit cc07abe

Please sign in to comment.