Use this controller to easily map a folder full of Markdown documents to a web route, via a simple Controller. No database needed (no migrations).
You can install the package via composer:
composer require pforret/lara-markdown-controller
You can publish the config file with:
php artisan vendor:publish --tag="lara-markdown-controller-config"
This is the contents of the published config file:
return [
];
Optionally, you can publish the views using
php artisan vendor:publish --tag="lara-markdown-controller-views"
// create a new ContentController that extends Pforret\LaraMarkdownController
namespace App\Http\Controllers
class FaqController extends Pforret\LaraMarkdownController
{
public function __construct(){
$this->setMarkdownRoot("pages/faq"); // relative to project root i.e. base_path()
$this->setTitle("Frequently Asked Questions");
}
}
// and add this to your routes/web.php
Route::resource('faq', FaqController::class)
->only(['index', 'show'])
->names("faq");
// now the /faq route will list all files and /faq/why will render the pages/faq/why.md with FrontMatter and Markdown->HTML conversion
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.