public function __construct(Yaml $yaml) { if (!is_readable(blog_path('blog.yaml'))) { throw new Exception(500); } $blog = $yaml->parse(file_get_contents(blog_path('blog.yaml'))); $this->posts = isset($blog['posts']) ? $blog['posts'] : array(); $this->addSlugs(); $this->sortPosts(); return $this->posts; }
public function load($slug, $info) { if (!is_readable(blog_path($slug . ".md"))) { throw new Exception(404); } $contents = file_get_contents(blog_path($slug . ".md")); $this->title = $info['title']; $this->published = $info['published']; $this->image = $info['image']; $this->intro = $info['intro']; $this->content = $this->markdown->parse($contents); }