Skip to content

pforret/lara-markdown-controller

Repository files navigation

Laravel Markdown Folder Controller

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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).

Installation

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"

Usage

// 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

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.