Skip to content

Commit 9b9a186

Browse files
committed
Improve description generation
1 parent 2fec7f9 commit 9b9a186

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/View/Components/Cachet.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ public function __construct(
2525
}
2626

2727
$this->title ??= ($this->appSettings->name ?? config('cachet.title'));
28-
$this->description ??= (Str::of($this->appSettings->about)->trim()->toString());
28+
$this->description ??= Str::of($this->appSettings->about)
29+
->markdown()
30+
->stripTags()
31+
->replaceMatches('/\s\s+|\n/', ' ')
32+
->trim()
33+
->limit(155, preserveWords: true) // 155 is the recommended length of a meta description...
34+
->toString();
2935
}
3036

3137
/**

0 commit comments

Comments
 (0)