labrodev/laravel-markdownable
最新稳定版本:v1.0.0
Composer 安装命令:
composer require labrodev/laravel-markdownable
包简介
Read Markdown files with YAML front matter, convert to HTML, and expose page data.
README 文档
README
Read Markdown files with YAML front matter, convert to HTML, and expose structured page data.
Features
- MarkdownPageFileReader — Read
.mdfiles by slug, list pages, resolve paths. - FrontMatterParser — Parse YAML front matter and body (Spatie YAML Front Matter).
- MarkdownToHtmlConverter — Convert Markdown to HTML (League CommonMark, GFM).
- MarkdownPageReader — Orchestrator: read → parse → convert → return
PageData. - PageData — Readonly value object with slug, title, meta fields, body, bodyHtml;
toArray()for views/SEO. - Contracts —
MarkdownPageFileReaderContract,FrontMatterParserContract,MarkdownConverterContractfor type-hinting and swapping implementations or mocks. - Markdownable facade — Static access to the page reader.
Installation
composer require labrodev/laravel-markdownable
The service provider is registered automatically.
Configuration
The package uses config('site.content.paths.pages') by default for the pages directory. To override, publish the config or set MARKDOWNABLE_PAGES_PATH in your .env.
php artisan vendor:publish --tag=markdownable-config
Usage
use Labrodev\Markdownable\Facades\Markdownable; $page = Markdownable::getPageBySlug('about'); if ($page !== null) { $page->title; // string $page->bodyHtml; // string (HTML) $page->toArray(); // array for Blade/SEO (slug, title, meta_title, meta_description, og_image, sitemap, canonical, body, body_html) }
Use PageData::toArray() when passing to Blade or SEO so keys match the usual array shape (meta_title, meta_description, og_image, body_html, etc.).
Development
cd package/laravel-markdownable composer install composer run test # Pest composer run pint # Lint (read-only) composer run pint:fix # Format composer run stan # PHPStan composer run analysis # Pint fix + PHPStan
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-07