mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Add canonical URL to discussion list (#1814)
This commit is contained in:
parent
a737b98e7f
commit
54f733ca80
|
@ -12,6 +12,8 @@ namespace Flarum\Forum\Content;
|
|||
use Flarum\Api\Client;
|
||||
use Flarum\Api\Controller\ListDiscussionsController;
|
||||
use Flarum\Frontend\Document;
|
||||
use Flarum\Http\UrlGenerator;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Support\Arr;
|
||||
|
@ -29,14 +31,28 @@ class Index
|
|||
*/
|
||||
protected $view;
|
||||
|
||||
/**
|
||||
* @var SettingsRepositoryInterface
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var UrlGenerator
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @param Client $api
|
||||
* @param Factory $view
|
||||
* @param SettingsRepositoryInterface $settings
|
||||
* @param UrlGenerator $url
|
||||
*/
|
||||
public function __construct(Client $api, Factory $view)
|
||||
public function __construct(Client $api, Factory $view, SettingsRepositoryInterface $settings, UrlGenerator $url)
|
||||
{
|
||||
$this->api = $api;
|
||||
$this->view = $view;
|
||||
$this->settings = $settings;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function __invoke(Document $document, Request $request)
|
||||
|
@ -56,9 +72,11 @@ class Index
|
|||
];
|
||||
|
||||
$apiDocument = $this->getApiDocument($request->getAttribute('actor'), $params);
|
||||
$defaultRoute = $this->settings->get('default_route');
|
||||
|
||||
$document->content = $this->view->make('flarum.forum::frontend.content.index', compact('apiDocument', 'page'));
|
||||
$document->payload['apiDocument'] = $apiDocument;
|
||||
$document->canonicalUrl = $defaultRoute === '/all' ? $this->url->to('forum')->base() : $request->getUri()->withQuery('');
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user