Skip to content

Commit f6d3a16

Browse files
committed
Add embedded youtube links
1 parent eaaded5 commit f6d3a16

File tree

9 files changed

+274
-83
lines changed

9 files changed

+274
-83
lines changed

app/Markdown/MarkdownServiceProvider.php

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Support\ServiceProvider;
66
use League\CommonMark\Environment\Environment;
77
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
8+
use League\CommonMark\Extension\Embed\Bridge\OscaroteroEmbedAdapter;
9+
use League\CommonMark\Extension\Embed\EmbedExtension;
810
use League\CommonMark\Extension\ExternalLink\ExternalLinkExtension;
911
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
1012
use League\CommonMark\Extension\Mention\MentionExtension;
@@ -31,11 +33,17 @@ public function register(): void
3133
'open_in_new_window' => true,
3234
'nofollow' => ($params['nofollow'] ?? true) ? 'external' : '',
3335
],
36+
'embed' => [
37+
'adapter' => new OscaroteroEmbedAdapter,
38+
'allowed_domains' => ['youtube.com', 'twitter.com'],
39+
'fallback' => 'link',
40+
],
3441
]);
3542

3643
$environment->addExtension(new CommonMarkCoreExtension);
3744
$environment->addExtension(new GithubFlavoredMarkdownExtension);
3845
$environment->addExtension(new MentionExtension);
46+
$environment->addExtension(new EmbedExtension);
3947
$environment->addExtension(new ExternalLinkExtension);
4048

4149
return new LeagueConverter(new MarkdownConverter($environment));

app/Models/Article.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function body(): string
100100

101101
public function excerpt(int $limit = 100): string
102102
{
103-
return Str::limit(strip_tags(md_to_html($this->body(), false)), $limit);
103+
return Str::limit(strip_tags(md_to_html($this->body())), $limit);
104104
}
105105

106106
public function hasHeroImageAuthor(): bool

app/Models/Reply.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function body(): string
7676

7777
public function excerpt(int $limit = 100): string
7878
{
79-
return Str::limit(strip_tags(md_to_html($this->body())), $limit);
79+
return Str::limit(strip_tags(md_to_html($this->body(), ['nofollow' => false])), $limit);
8080
}
8181

8282
public function to(ReplyAble $replyAble)

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"blade-ui-kit/blade-heroicons": "^2.3",
1010
"blade-ui-kit/blade-icons": "^1.6",
1111
"codeat3/blade-simple-icons": "^6.2",
12+
"embed/embed": "^4.4",
1213
"guzzlehttp/guzzle": "^7.2",
1314
"innocenzi/bluesky-notification-channel": "^0.2.0",
1415
"intervention/image": "^3.0",

composer.lock

+250-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/css/app.css

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
@import 'highlight.js/styles/hybrid.css' layer(base);
55

6-
@import './articles.css' layer(utilities);
76
@import './buttons.css' layer(utilities);
87
@import './labels.css' layer(utilities);
98
@import './modal.css' layer(utilities);
@@ -171,3 +170,13 @@ svg .secondary {
171170
.editor li[aria-selected='true'] {
172171
@apply bg-lio-100;
173172
}
173+
174+
article iframe {
175+
@apply w-full h-64;
176+
}
177+
178+
@media (width >= theme(--breakpoint-sm)) {
179+
article iframe {
180+
@apply h-96;
181+
}
182+
}

0 commit comments

Comments
 (0)