Banners support markdown now.
This commit is contained in:
parent
899691b710
commit
67963c8268
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
Graphictoria 2022
|
||||||
|
A bit of a hacky way to implement markdown with laravel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use Illuminate\Support\HtmlString;
|
||||||
|
use League\CommonMark\Environment\Environment;
|
||||||
|
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||||
|
use League\CommonMark\Extension\Table\TableExtension;
|
||||||
|
use League\CommonMark\MarkdownConverter;
|
||||||
|
|
||||||
|
class MarkdownHelper
|
||||||
|
{
|
||||||
|
// XlXi: This bit was taken from https://github.com/laravel/framework/blob/b9203fca96960ef9cd8860cb4ec99d1279353a8d/src/Illuminate/Mail/Markdown.php line 106
|
||||||
|
public static function parse($text) {
|
||||||
|
$environment = new Environment([
|
||||||
|
//
|
||||||
|
]);
|
||||||
|
|
||||||
|
$environment->addExtension(new CommonMarkCoreExtension);
|
||||||
|
$environment->addExtension(new TableExtension);
|
||||||
|
|
||||||
|
$converter = new MarkdownConverter($environment);
|
||||||
|
|
||||||
|
return new HtmlString($converter->convert($text)->getContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -94,7 +94,7 @@
|
||||||
<div class="graphictoria-nav-margin"></div>
|
<div class="graphictoria-nav-margin"></div>
|
||||||
@foreach(App\Models\Banner::all() as $banner)
|
@foreach(App\Models\Banner::all() as $banner)
|
||||||
<div @class(['alert', 'alert-' . $banner->style, 'graphictoria-alert', 'alert-dismissible' => $banner->dismissable])>
|
<div @class(['alert', 'alert-' . $banner->style, 'graphictoria-alert', 'alert-dismissible' => $banner->dismissable])>
|
||||||
<p class="mb-0">{{ $banner->message }}</p>
|
<p class="mb-0">{{ \App\Helpers\MarkdownHelper::parse($banner->message) }}</p>
|
||||||
@if($banner->dismissable)
|
@if($banner->dismissable)
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue