seo fixes

This commit is contained in:
2026-08-09 04:19:21 +03:00
parent df2128ebff
commit bed4c48900
19 changed files with 368 additions and 25 deletions
+16 -4
View File
@@ -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