Example #1
0
 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;
 }
Example #2
0
 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);
 }