Update (view): redesign

This commit is contained in:
2023-10-05 00:29:23 +08:00
parent f1f02bb7b6
commit 7374d66a21
14 changed files with 104 additions and 49 deletions

View File

@@ -22,7 +22,7 @@ public function redirect(Request $request, $slug)
return abort(404);
}
return redirect()->route('front.post',['category_slug' => $post->category->slug, 'slug' => $post->slug]);
return redirect()->route('front.post', ['category_slug' => $post->category->slug, 'slug' => $post->slug]);
}
@@ -104,7 +104,7 @@ public function index(Request $request, $category_slug, $slug)
->addValue('dateCreated', $post->created_at->format('Y-m-d'))
->addValue('dateModified', $post->updated_at->format('Y-m-d'))
->addValue('description', $post_description)
->addValue('articleBody', trim(preg_replace('/\s\s+/', ' ', strip_tags($content))));
->addValue('articleBody', plain_text($content));
// breadcrumb json ld
$listItems = [];
@@ -161,7 +161,7 @@ private function injectBootstrapClasses($content)
if (strpos($pNode->text(), 'Q:') === 0) {
$currentClasses = $pNode->attr('class');
$newClasses = trim($currentClasses.' fw-bold');
$newClasses = trim($currentClasses.' ');
$pNode->getNode(0)->setAttribute('class', $newClasses);
}
});
@@ -234,7 +234,7 @@ private function injectPublishDateAndAuthor($post, $content)
$authorName = $post->author->name;
// Create the HTML structure for publish date and author
$publishInfo = "<div class=\"mb-4\"><span class=\"text-secondary small\">Published on {$publishedAtFormatted} by {$authorName}</span></div>";
$publishInfo = "<div class=\"mb-4\"><span class=\"text-secondary small\">Published on {$publishedAtFormatted} by {$authorName}<i class=\"bi bi-dot\"></i>" . markdown_min_read($post->body) . "</span></div>";
// Inject the publish date and author information after the `h1` tag
$content = preg_replace('/(<\/h1>)/', '$1'.$publishInfo, $content, 1);