labrodev/laravel-markdownable
Laravel package to load Markdown pages with YAML front matter by slug, parse metadata, convert to HTML, and return a structured PageData object. Includes contracts for swapping implementations and a Markdownable facade for simple access.
PageData::toArray() simplifies rendering via Blade (@foreach($pages as $page)).meta_description) can be directly mapped to Laravel’s SEO packages (e.g., spatie/laravel-seo).MarkdownPageFileReaderContract).PageData (e.g., Cache::remember()) or pre-render HTML during deployments.config('site.content.paths.pages') requires manual setup; risk of misconfiguration.bootstrap/app.php or use environment variables.MarkdownToHtmlConverter or switch to a more flexible parser (e.g., cebe/markdown).updated_at timestamp in front matter.PageData be cached per-request, per-deployment, or via a CDN (e.g., Varnish)?spatie/laravel-seo (map PageData to meta tags).laravel/cache (cache PageData or HTML).spatie/laravel-medialibrary (if markdown files need to be stored in S3).bodyHtml directly or use @verbatim for raw HTML.PageData as props for dynamic content.about.md, contact.md) to markdown files.Markdownable::getPageBySlug().MarkdownPageReader to support API routes (e.g., GET /api/pages/{slug}).PageData::toArray() for JSON responses.Cache::tags('pages')->remember()).spatie/laravel-webhooks).composer.json).cebe/markdown for advanced features if needed.MarkdownPageFileReader.MARKDOWNABLE_PAGES_PATH in .env (e.g., storage/app/markdown)./storage/app/markdown/
├── about.md
└── blog/
├── post-1.md
└── post-2.md
Markdownable::getPageBySlug().@php $page = Labrodev\Markdownable\Facades\Markdownable::getPageBySlug('about') @endphp
<h1>{{ $page->title }}</h1>
{!! $page->bodyHtml !!}
MarkdownPageFileReaderContract for unit tests.Cache::forever() for static pages).storage/app/markdown has secure file permissions (e.g., chmod 755).storage/app/markdown/about.md and commit").MARKDOWNABLE_PAGES_PATH and file permissions.bodyHtml for malformed HTML.MarkdownPageReader.
PageData or list pages (e.g., Markdownable::listPages()) at startup.spatie/laravel-queueable to defer parsing for dynamic pages.bodyHtml to a CDN (e.g., Cloudflare) if content is rarely updated.MarkdownPageReader execution time in Laravel Telescope or Sentry.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Missing markdown file | Broken page rendering | Fallback to a 404 template or default content. |
| Malformed YAML front matter | Parser errors (e.g., YamlException) |
Validate YAML schema or use a lenient parser. |
| Disk full / permission denied | File read failures | Monitor disk space; use storage:link for S3. |
How can I help you explore Laravel packages today?