<?php

use Timber\Timber;

$context          = Timber::context();
$timberPost       = Timber::get_post();
$context['posts'] = Timber::get_posts();

$templates = ['pages/index.twig'];

if (is_home()) {
    array_unshift($templates, 'pages/front-page.twig', 'pages/home.twig');
}

if (!$timberPost) {
    Timber::render('pages/404.twig', $context);
    return;
}

if (post_password_required($timberPost->ID)) {
    Timber::render('pages/single-password.twig', $context);
    return;
}

Timber::render($templates, $context);
