✨ feat: allow showcasing featured projects on homepage (#297)
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
|
||||
{%- set max_projects = max_projects | default(value=999999) -%}
|
||||
<div class="cards">
|
||||
{%- for page in show_pages %}
|
||||
{# Used only in main page #}
|
||||
{% if loop.index > max_projects %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{# Determine which URL to use, default is page.permalink #}
|
||||
{%- if page.extra.link_to and config.markdown.external_links_target_blank -%}
|
||||
{%- set blank_target = "target=_blank" -%}
|
||||
|
18
templates/partials/main_page_posts_list.html
Normal file
18
templates/partials/main_page_posts_list.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<div class="list">
|
||||
<div>
|
||||
{{ macros_page_header::page_header(title=section.title) }}
|
||||
</div>
|
||||
|
||||
{%- if paginator %}
|
||||
{%- set pages = paginator.pages -%}
|
||||
{% else %}
|
||||
{%- set pages = extra_section.pages -%}
|
||||
{% endif -%}
|
||||
|
||||
{% set max_posts = section.extra.max_posts | default(value=999999) %}
|
||||
{{ macros_list_posts::list_posts(posts=pages, max=max_posts, language_strings=language_strings, section_path=path) }}
|
||||
</div>
|
||||
|
||||
{% if paginator %}
|
||||
{%- include "partials/paginate.html" -%}
|
||||
{% endif %}
|
17
templates/partials/main_page_projects_list.html
Normal file
17
templates/partials/main_page_projects_list.html
Normal file
@@ -0,0 +1,17 @@
|
||||
{% if section.extra.projects_path %}
|
||||
{%- set projects_section = get_section(path=section.extra.projects_path) -%}
|
||||
{%- if projects_section -%}
|
||||
<div id="featured-projects" class="list">
|
||||
{{ macros_page_header::page_header(title=macros_translate::translate(key="featured_projects", default="Featured projects", language_strings=language_strings)) }}
|
||||
</div>
|
||||
{%- set show_pages = projects_section.pages -%}
|
||||
{%- set max_projects = section.extra.max_projects | default(value=3) -%}
|
||||
{%- include "partials/cards_pages.html" -%}
|
||||
{%- endif -%}
|
||||
{%- if show_pages | length > max_projects -%}
|
||||
<div class="all-posts {{ first_section }}-first" id="all-projects">
|
||||
<a href="{{ get_url(path=projects_section.path, lang=lang) }}/">{{ macros_translate::translate(key="all_projects", default="All projects", language_strings=language_strings) }} <span class="arrow">⟶</span></a>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{% endif %}
|
@@ -2,7 +2,18 @@
|
||||
|
||||
{% block main_content %}
|
||||
|
||||
<main>
|
||||
{%- set show_projects_first = section.extra.show_projects_first | default(value=false) -%}
|
||||
{%- if show_projects_first -%}
|
||||
{%- set first_section = "projects" -%}
|
||||
{%- else -%}
|
||||
{%- set first_section = "posts" -%}
|
||||
{%- endif -%}
|
||||
|
||||
<main class={{ first_section }}-first>
|
||||
{%- if section.extra.header %}
|
||||
{%- include "partials/home_banner.html" -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if section.extra.section_path -%}
|
||||
{% set extra_section = get_section(path=section.extra.section_path) %}
|
||||
{% endif -%}
|
||||
@@ -13,28 +24,13 @@
|
||||
{% set path = section.path %}
|
||||
{% endif -%}
|
||||
|
||||
{%- if section.extra.header %}
|
||||
{%- include "partials/home_banner.html" -%}
|
||||
{% endif -%}
|
||||
|
||||
<div class="list">
|
||||
<div>
|
||||
{{ macros_page_header::page_header(title=section.title) }}
|
||||
</div>
|
||||
|
||||
{%- if paginator %}
|
||||
{%- set pages = paginator.pages -%}
|
||||
{% else %}
|
||||
{%- set pages = extra_section.pages -%}
|
||||
{% endif -%}
|
||||
|
||||
{% set max = section.extra.max_posts | default(value=999999) %}
|
||||
{{ macros_list_posts::list_posts(posts=pages, max=max, language_strings=language_strings, section_path=path) }}
|
||||
</div>
|
||||
{%- if show_projects_first -%}
|
||||
{%- include "partials/main_page_projects_list.html" -%}
|
||||
{%- include "partials/main_page_posts_list.html" -%}
|
||||
{%- else -%}
|
||||
{%- include "partials/main_page_posts_list.html" -%}
|
||||
{%- include "partials/main_page_projects_list.html" -%}
|
||||
{%- endif -%}
|
||||
</main>
|
||||
|
||||
{% if paginator %}
|
||||
{%- include "partials/paginate.html" -%}
|
||||
{% endif %}
|
||||
|
||||
{% endblock main_content %}
|
||||
|
Reference in New Issue
Block a user