Blog Title

blog-image
  • Cat Name
  • 2025-10-05
4

"Got it! Since $blog->content is no longer an array, your current loop will break. You just need to convert it as a single string instead of looping.

u2705 Hereu2019s the updated show method for Markdown/Text/HTML:

use League\CommonMark\CommonMarkConverter;

public function show(Blog $blog) { $converter = new CommonMarkConverter();

// Convert the content safely (string only) $content = $converter->convertToHtml($blog->content ?? '');

return view('blog-details', compact('blog', 'content')); }

u2705 Why this works:

  • convertToHtml() expects a single string.
  • Since content is no longer an array, the foreach block is not needed.
  • The output $content will now be an HTML-safe string you can print in the view.

If you're still storing HTML directly (instead of Markdown), and want to detect & convert only Markdown, let me know u2014 I can add a conditional handler too."