Skip to content

Commit

Permalink
Allow access to posts outside of blog #10
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbitron committed Mar 18, 2015
1 parent ab96782 commit b092b5e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Baun.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,22 @@ protected function setupRoutes()
$files = $this->getFiles($this->config->get('app.content_path'), $this->config->get('app.content_extension'));
$this->events->emit('baun.getFiles', $files);

$posts = null;
if ($this->blogPath) {
$posts = $this->filesToPosts($files);
$this->events->emit('baun.filesToPosts', $posts);
}

$navigation = $this->filesToNav($files, $this->router->currentUri());
$this->events->emit('baun.filesToNav', $navigation);
$this->theme->custom('baun_nav', $navigation);

$routes = $this->filesToRoutes($files);
$this->events->emit('baun.filesToRoutes', $routes);
foreach ($routes as $route) {
$this->router->add('GET', $route['route'], function() use ($route) {
$this->router->add('GET', $route['route'], function() use ($route, $posts) {
$data = $this->getFileData($route['path']);
$data['posts'] = $posts;
$template = 'page';
if (isset($data['info']['template']) && $data['info']['template']) {
$template = $data['info']['template'];
Expand All @@ -167,9 +174,7 @@ protected function setupRoutes()
});
}

if ($this->blogPath) {
$posts = $this->filesToPosts($files);
$this->events->emit('baun.filesToPosts', $posts);
if ($posts) {
if (!empty($posts)) {
foreach ($posts as $post) {
$this->router->add('GET', $post['route'], function() use ($post, $posts) {
Expand Down

0 comments on commit b092b5e

Please sign in to comment.