{% set blogs = repository('Plugin\\CMBlogPro\\Entity\\Blog').getList() %}
{% set count = 0 %}
{% if blogs is defined and blogs|length > 0 %}
{% for blog in blogs %}
{% if count < maxCount %}
{# 特定カテゴリを含む ∨ 含まない処理 #}
{% set isInclude = false %}
{% set isExclude = true %}
{% if includeCategories is empty %}
{% set isInclude = true %}
{% else %}
{% for blogCategory in blog.BlogCategories %}
{% if blogCategory.CategoryId in includeCategories %}
{% set isInclude = true %}
{% endif %}
{% endfor %}
{% endif %}
{% if excludeCategories is empty %}
{% else %}
{% for blogCategory in blog.BlogCategories %}
{% if blogCategory.CategoryId in excludeCategories %}
{% set isExclude = false %}
{% endif %}
{% endfor %}
{% endif %}
{% if isInclude == true and isExclude == true %}
{% set count = count + 1 %}
<li class="home__blog-item">
<a href="{{ url('blog_detail/{id}', {'id': blog.slug ? blog.slug : blog.id}) }}">
<div class="home__blog-img-wrapper">
{% if blog.getMainListImage %}
<img src="{{ asset(blog.getMainListImage|no_image_product, 'save_image') }}" class='item_blog_image'></img>
{% else %}
<img src="{{ asset(''|no_image_product, 'save_image') }}" class='item_blog_image'></img>
{% endif %}
</div>
<div class="home__blog-text-wrapper">
<h3>{{ blog.getTitle|length > 40 ? blog.getTitle|striptags|replace({(' '):' '})|slice(0, 40)|raw ~ '...' : blog.getTitle|raw }}</h3>
<p>{{ blog.getUpdateDate|date('Y年m月d日') }}</p>
</div>
</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}