diff --git a/main/models.py b/main/models.py index df2f8202af0a0cad8e7dbe7a48f6f5fa319c0077..683738d2b15fb94baaaaab385edc4ffeb7bc1341 100644 --- a/main/models.py +++ b/main/models.py @@ -165,7 +165,10 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin, context["article_data_list"] = MainArticlePage.objects.filter( region__isnull=False ).order_by("-date")[:3] - context["article_carousel_list"] = MainArticlePage.objects.order_by("-date")[:8] + + articles_for_article_section = MainArticlePage.objects.order_by("-date") + context["article_main"] = articles_for_article_section[:1] + context["article_carousel_list"] = articles_for_article_section[1:8] return context diff --git a/main/templates/main/blocks/news_block.html b/main/templates/main/blocks/news_block.html index ac0d3bc63477d1a831ff478d7ab860c3d6513a54..0dc78b4893a57681d22f287ba9574efe34287ec1 100644 --- a/main/templates/main/blocks/news_block.html +++ b/main/templates/main/blocks/news_block.html @@ -5,21 +5,23 @@ <h2 class="head-7xl xl:text-center mb-6 xl:mb-28"> {{ self.title }} </h2> - <div class="flex flex-wrap mb-5 lg:mb-10"> - {% image article_data_list.0.image original as article_img %} - <img src="{{ article_img.url }}" draggable="false" alt="" class="lg:max-w-lg lg:mr-11 h-fit"> - <div class="flex flex-col max-w-xl items-start"> - <span class="text-green-500 head-3xl mt-10 mb-4 lg:mb-8">{{ article_data_list.0.date }}</span> - <h5 class="head-4xl mb-5 lg:mb-10">{{ article_data_list.0.title }}</h5> - <p class="leading-6 mb-4 lg:mb-8">{{ article_data_list.0.perex }}</p> - {% include 'main/includes/button_animated.html' with btn_link=article_data_list.0.url btn_text="Číst dále" %} + {% if article_main %} + <div class="flex flex-wrap mb-5 lg:mb-10"> + {% image article_main.image original as article_img %} + <img src="{{ article_img.url }}" draggable="false" alt="" class="lg:max-w-lg lg:mr-11 h-fit"> + <div class="flex flex-col max-w-xl items-start"> + <span class="text-green-500 head-3xl mt-10 mb-4 lg:mb-8">{{ article_main.date }}</span> + <h5 class="head-4xl mb-5 lg:mb-10">{{ article_main.title }}</h5> + <p class="leading-6 mb-4 lg:mb-8">{{ article_main.perex }}</p> + {% include 'main/includes/button_animated.html' with btn_link=article_main.url btn_text="Číst dále" %} + </div> </div> - </div> - <div class="__js-root"> - <ui-article-carousel> - {% include 'main/includes/article_carousel_item.html' with article_carousel_list=article_carousel_list %} - </ui-article-carousel> - </div> + <div class="__js-root"> + <ui-article-carousel> + {% include 'main/includes/article_carousel_item.html' with article_carousel_list=article_carousel_list %} + </ui-article-carousel> + </div> + {% endif %} </div> </div>