can anyone help me optimize the following code, when I activate this code the build time increases, while when I deactivate it the build time decreases by about 2 minutes, my website has 884 pages and 17 sections (multilingual website)
{% if custom.show_related_articles %}
{% set section = get_section(path=“posts/” ~ “_index” ~ bahasa ~ “.md”) %}
{% set_global read_more_posts = %}
{% for post in section.pages %}
{% if page.slug == post.slug %}
{% continue %}
{% endif %}
{% set_global read_more_posts = [post] | concat(with=read_more_posts) %}
{% if read_more_posts | length >= 4 %}
{% break %}
{% endif %}
{% endfor %}
{% if read_more_posts | length > 0 %}
<section class="gh-container is-grid gh-outer">
<div class="gh-container-inner gh-inner">
<h2 class="gh-container-title">{{bh::get(tr=lang_conf, key="read_more", def="Read more")}}</h2>
<div class="gh-feed">
{% for post in read_more_posts %}
{{ pc::postcard(post=post, lazyLoad=true) }}
{% endfor %}
</div>
</div>
</section>
{% endif %}
{% endif %}