mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 10:50:50 +08:00
Add more attributes in app.blade.php and add a setDescription method. (#1105)
* Added `language` and `direction` properties to WebAppView * Use properties `language` and `direction` in app.blade.php * Added WebAppView::setDescription to set the meta description * Whoops! Changed "ltr" to \'ltr\'. Thanks StyleCI :) * Removed unnecessary `= null` for * Changed `.. ? .. : ..` to `.. ?: ..`. Useful thing right there ;)
This commit is contained in:
parent
01eba18164
commit
fcfc1b2a37
|
@ -41,6 +41,20 @@ class WebAppView
|
|||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* The language of the document, displayed as the value of the attribute `dir` in the <html> tag.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* The text direction of the document, displayed as the value of the attribute `dir` in the <html> tag.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
protected $direction;
|
||||
|
||||
/**
|
||||
* The path to the client layout view to display.
|
||||
*
|
||||
|
@ -188,6 +202,36 @@ class WebAppView
|
|||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of the document, displayed in a <meta> tag.
|
||||
*
|
||||
* @param null|string $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* The language of the document, displayed as the value of the attribute `dir` in the <html> tag.
|
||||
*
|
||||
* @param null|string $language
|
||||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* The language of the document, displayed as the value of the attribute `dir` in the <html> tag.
|
||||
*
|
||||
* @param null|string $direction
|
||||
*/
|
||||
public function setDirection($direction)
|
||||
{
|
||||
$this->direction = $direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SEO content of the page, to be displayed in <noscript> tags.
|
||||
*
|
||||
|
@ -283,7 +327,9 @@ class WebAppView
|
|||
$view = $this->view->file(__DIR__.'/../../../views/app.blade.php');
|
||||
|
||||
$view->title = $this->buildTitle(array_get($forum, 'data.attributes.title'));
|
||||
$view->description = $this->description;
|
||||
$view->description = $this->description ?: array_get($forum, 'data.attributes.description');
|
||||
$view->language = $this->language ?: $this->locales->getLocale();
|
||||
$view->direction = $this->direction ?: 'ltr';
|
||||
|
||||
$view->modules = $this->modules;
|
||||
$view->payload = $this->buildPayload($request, $forum);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<html dir="{{ $direction }}" lang="{{ $language }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ $title }}</title>
|
||||
|
|
Loading…
Reference in New Issue
Block a user