2017 © Pedro Peláez
 

library eloquent-markdown

Mix markdown, frontmatter and eloquent models to easily handle markdown files with meta information by treating them as objects.

image

hyn/eloquent-markdown

Mix markdown, frontmatter and eloquent models to easily handle markdown files with meta information by treating them as objects.

  • Thursday, December 29, 2016
  • by Luceos
  • Repository
  • 1 Watchers
  • 4 Stars
  • 132 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Eloquent markdown

GitHub license Latest Stable Version Build Status Total Downloads Donate, (*1)

Ever felt like your markdown files could use meta information.. And once you've added frontmatter logic, whether it would be amazing to handle those files more humanely.., (*2)

So let's combine markdown files, frontmatter and eloquent!, (*3)

That something like the below:, (*4)

{
  "title": "Some elaborate .."
}
And of course your regular markdown nonsense.

Mutates into an object:, (*5)

echo $page->title; // Some elaborate ..
echo $page->getRenderedMarkdown(); // <p>And of course your regular markdown nonsense.</p>
echo $page->getMarkdown(); // And of course your regular markdown nonsense.
$page->setMarkdown('Foojaa'); // Yes update
$page->markdown = 'Foobar'; // Or on the assigned property
$page->save(); // Write the file to disk, YES!

Installation

composer require hyn/eloquent-markdown

Now create a model you want to use for markdown files:, (*6)

class Page extends \Hyn\Eloquent\Markdown\Model
{}

And setup the filesystem and markdown parser resolution, add in AppServiceProvider or somewhere:, (*7)

use Hyn\Eloquent\Markdown\Model;
use Hyn\Frontmatter\Parser;
use cebe\markdown\Markdown;

// ..

public function register() {
            Model::setMarkdownParser(new Parser(new Markdown));
            Model::setFilesystem($this->app->make('filesystem')->disk('content'));
}

Set content to the disk you configured to load the markdown files from. Or instantiate your own filesystem instance., (*8)

Usage

So if you have a file some/foo.md, use Page::find('some/foo.md'); to create a Page object, where any frontmatter meta information is stored as properties, the markdown contents are stored in the original state as the markdown property and the generated html is assigned to the contents attribute., (*9)

Other stuff that works:, (*10)

  • save()
  • delete()
  • update the markdown property to renew the rendered content property automatically

The Versions

29/12 2016

dev-master

9999999-dev

Mix markdown, frontmatter and eloquent models to easily handle markdown files with meta information by treating them as objects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniël `Luceos` Klabbers

14/12 2016

1.1

1.1.0.0

Mix markdown, frontmatter and eloquent models for bling bling

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniël `Luceos` Klabbers

14/12 2016

1.0

1.0.0.0

Mix markdown, frontmatter and eloquent models for bling bling

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniël `Luceos` Klabbers