-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathContent.php
executable file
·68 lines (62 loc) · 2.28 KB
/
Content.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace App\View\Components\Docs;
use App\View\Modifications\BladeComponentModifier;
use App\View\Modifications\BlockquoteColorModifier;
use App\View\Modifications\HeaderLinksModifier;
use App\View\Modifications\HTMLCleanseModifier;
use App\View\Modifications\ImageAltModifier;
use App\View\Modifications\RemoveFirstHeaderModifier;
use App\View\Modifications\ResponsiveTableModifier;
use App\View\Modifications\TypografModifier;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Pipeline\Pipeline;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\Component;
class Content extends Component implements Htmlable
{
/**
* @var string
*/
protected $content;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(string $content)
{
$this->content = $content;
}
/**
* Get the view / contents that represent the component.
*
* @throws \DOMException
*
* @return \App\View\Components\DocsContent
*/
public function render()
{
return $this;
}
/**
* @return string
*/
public function toHtml(): string
{
return Cache::remember('doc-content-'.sha1($this->content), now()->addWeek(), function () {
return app(Pipeline::class)
->send($this->content)
->through([
HTMLCleanseModifier::class, // Стандартизирует HTML
BlockquoteColorModifier::class, // Применяет цвет к блокам цитат (Например предупреждение)
RemoveFirstHeaderModifier::class, // Удаляет h1 заголовок
HeaderLinksModifier::class, // Добавляет ссылки для заголовков
ResponsiveTableModifier::class, // Добавляет к таблице класс table-responsive
BladeComponentModifier::class, // Применяет компоненты blade
ImageAltModifier::class, // Добавляет alt к картинкам
TypografModifier::class, // Применяет типограф к тексту
])
->thenReturn();
});
}
}