<h2>Blind Spot Monitor</h2>
<div class="frame-wrap">
	<div class="frame-sidebar">
		{% include '@p1cm/help.twig' %}
	</div>
    
	<div class="frame-content">
        {# <?php if(isset($primary_blind_spot) && count($primary_blind_spot) > 0): ?> #}
        {% if primary_blind_spot and primary_blind_spot|length > 0 %}
        <div class="frame-box">
            <h4>Posts unranked for their Primary Keyword</h4>
            <div class="container p1cm-container">
                <div class="row p1cm-posts">
                {# <?php foreach($primary_blind_spot as $post): ?> #}
                {% for post in primary_blind_spot %}
                    <div class="col-md-12 p1cm-post">
                        <div class="row">
                            <div class="col-md-12">
                                <h4 class="p1cm-heading"><a href="{{ post.permalink|raw }}">{{ post.title }}</a></h4>
                                <a href="{{ post.edit_link|raw }}" class="p1cm-editBtn" type="button">- Edit</a>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <strong>Primary Keyword: </strong>
                                {# <?php echo isset($post['meta']['primary_keyword']) 
                                            ? $post['meta']['primary_keyword'] 
                                            : '<span class="p1cm-red">Not Assigned</span>'; ?> #}
                                {% if post.meta.primary_keyword %}
                                    {{ post.meta.primary_keyword }}
                                {% else %}
                                    <span class="p1cm-red">Not Assigned</span>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                {# <?php endforeach; ?> #}
                {% endfor %}
                </div>
            </div>
        </div>
        {# <?php endif; ?> #}
        {% endif %}
        {# <?php if(isset($secondary_blind_spot) && count($secondary_blind_spot) > 0): ?> #}
        {% if secondary_blind_spot and secondary_blind_spot|length > 0 %}
        <div class="frame-box">
            <h4>Posts ranked higher for their Secondary Keywords</h4>
            <div class="container p1cm-container">
                <div class="row p1cm-posts">
                {# <?php foreach($secondary_blind_spot as $post): ?> #}
                {% for post in secondary_blind_spot %}
                    <div class="col-md-12 p1cm-post">
                        <div class="row">
                            <div class="col-md-12">
                                <h4 class="p1cm-heading"><a href="{{ post.permalink|raw }}">{{ post.title }}</a></h4>
                                <a href="{{ post.edit_link|raw }}" class="p1cm-editBtn" type="button">- Edit</a>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <strong>Primary Keyword: </strong>
                                {# <?php echo $post['meta']['primary_keyword']; ?> #}
                                {{ post.meta.primary_keyword }}
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <strong>Higher Ranked Secondary Keywords: </strong>
                                {# <?php
                                $words = array();
                                for($i = 1; $i <= 4; $i++) {
                                    if( ! isset($post['meta']["secondary_keyword$i"]) || empty($post['meta']["secondary_keyword$i"])
                                        || ! isset($post['meta']["secondary_rank$i"]) || ! $post['meta']["secondary_rank$i"]) {
                                        continue;
                                    }
                                    if( ! isset($post['meta']['primary_rank']) || ! $post['meta']['primary_rank'] || $post['meta']["secondary_rank$i"] < $post['meta']['primary_rank']) {
                                        $words[] = $post['meta']["secondary_keyword$i"];
                                    }
                                }
                                echo implode(', ', $words);
                                ?> #}
                                {{ post.blind_spot_words }}
                            </div>
                        </div>
                    </div>
                {# <?php endforeach; ?> #}
                {% endfor %}
                </div>
            </div>
        </div>
        {# <?php endif; ?> #}
        {% endif %}
	</div>
</div>
