$partial_article = file_get_contents(ROOT . '/templates/' . THEME . '/partials/article.html'); $partial_category = file_get_contents(ROOT . '/templates/' . THEME . '/partials/category.html'); $category_id = (int) $args['category_id']; $category = isset($args['category_id']) ? $args['category_id'] : Category::getFirst(); $categories = CategoryRender::render($category_id, $partial_category); $articles = PostRender::renderForCategory($category_id, $partial_article); $category = new Category($category_id); render_content(['articles' => $articles, 'category' => $categories]); }); // render a post Route::get('show_post', function ($args) { $partial_article = file_get_contents(ROOT . '/templates/' . THEME . '/partials/article.html'); $partial_category = file_get_contents(ROOT . '/templates/' . THEME . '/partials/category.html'); $post_id = isset($args['post_id']) ? (int) $args['post_id'] : NULL; $post = new Post($post_id); $articles = PostRender::renderPost(new Post($post_id), $partial_article); $categories = CategoryRender::render($post->category_id, $partial_category); render_content(['articles' => $articles, 'category' => $categories]); }); // default action Route::get('', function ($args) { $category_id = 1; $year = !empty($args['year']) ? (int) $args['year'] : date('Y'); Route::run('show_category', ['category_id' => $category_id, 'year' => $year]); }); // render page content function render_content($replaces) { $content = new Content(1); $layout_content = file_get_contents(ROOT . '/templates/' . THEME . '/layout.html'); $layout_content = str_replace('{theme}', THEME, $layout_content);