seo fixes
This commit is contained in:
+16
-4
@@ -79,10 +79,22 @@ class Post extends Model
|
||||
|
||||
protected function bodyHtml(): Attribute
|
||||
{
|
||||
return Attribute::get(fn () => Str::markdown($this->body, [
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]));
|
||||
return Attribute::get(function () {
|
||||
$html = Str::markdown($this->body, [
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]);
|
||||
|
||||
// The page template already renders the post title as an <h1>. If the
|
||||
// Markdown body also opens with a top-level heading repeating that
|
||||
// title, drop it so the page doesn't ship two identical <h1>s.
|
||||
return preg_replace_callback(
|
||||
'/^\s*<h1>(.*?)<\/h1>/is',
|
||||
fn ($matches) => trim(strip_tags($matches[1])) === trim($this->title) ? '' : $matches[0],
|
||||
$html,
|
||||
limit: 1
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
protected function excerptOrSummary(): Attribute
|
||||
|
||||
Reference in New Issue
Block a user