Initial support for configurable page/section home
This commit is contained in:
parent
e956b24458
commit
222d35bf3b
|
@ -35,7 +35,12 @@
|
|||
</header>
|
||||
<main{% if config.extra.max_width_for == "main" %} style="max-width: {{ config.extra.max_width }}"{% endif %}>
|
||||
{% block main %}
|
||||
{% if config.extra.home_section %}
|
||||
{% set home_section = config.extra.home_section ~ "/_index.md" %}
|
||||
{{ widgets::section(cur_section=get_section(path=widgets::i18n_path(path=home_section)), full_articles=config.extra.home_fullarticles) }}
|
||||
{% else %}
|
||||
{{ section.content | markdown | safe }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</main>
|
||||
<footer>
|
||||
|
|
|
@ -3,37 +3,5 @@
|
|||
{% block title %}{{ section.title }}{{ config.extra.title }}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<section class="h-feed">
|
||||
<h1><span class="p-name">{{ section.title }}</span>{% if paginator and paginator.number_pagers > 1 %} ({{ paginator.current_index }}/{{ paginator.number_pagers }}){% endif %}</h1>
|
||||
<a class="u-url" hidden aria-hidden=true href="{{ section.permalink }}">Permalink</a>
|
||||
{% set pages = paginator.pages| default(value=section.pages) %}
|
||||
{% for page in pages %}
|
||||
<article>
|
||||
<div>
|
||||
<a class="u-url" href="{{ page.permalink }}"><h2>{{ page.title }}</h2></a>
|
||||
{%- if page.date -%}<time class="dt-published" datetime="{{ page.date }}">📅 {{ page.date | date(format=trans(key="dateFormat", lang=lang)) }}</time>{%- endif -%}
|
||||
</div>
|
||||
{% if page.summary %}
|
||||
<div class="p-summary e-content">
|
||||
{{ page.summary | markdown | safe }}
|
||||
<a class="read-more" href="{{ page.permalink }}">--> {{ trans(key="readmore", lang=lang) }} <--</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="e-content">
|
||||
{{ page.content | markdown | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% if paginator and paginator.number_pagers > 1 %}
|
||||
<aside class="pagination">
|
||||
{% if paginator.previous %}
|
||||
<a href="{{ paginator.previous }}"><-- {{ trans(key="previousPage", lang=lang) }}</a>
|
||||
{% endif %}
|
||||
{% if paginator.next %}
|
||||
<a href="{{ paginator.next }}">{{ trans(key="nextPage", lang=lang) }} --></a>
|
||||
{% endif %}
|
||||
</aside>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
{{ widgets::section(cur_section=section, cur_paginator=paginator) }}
|
||||
{% endblock main %}
|
||||
|
|
|
@ -71,3 +71,41 @@ a submenu. A submenu is an actual list
|
|||
{%- endif -%}
|
||||
{% if path != '/' %}{{ path }}{% endif %}
|
||||
{%- endmacro strip_lang_from_path -%}
|
||||
|
||||
{# Need to use separate names for variables, otherwise the paginator
|
||||
collides with that of index.html #}
|
||||
{% macro section(cur_section, cur_paginator=false, full_articles=true) %}
|
||||
<section class="h-feed">
|
||||
<h1><span class="p-name">{{ cur_section.title }}</span>{% if cur_paginator and cur_paginator.number_pagers > 1 %} ({{ cur_paginator.current_index }}/{{ cur_paginator.number_pagers }}){% endif %}</h1>
|
||||
<a class="u-url" hidden aria-hidden=true href="{{ cur_section.permalink }}">Permalink</a>
|
||||
{% set pages = cur_paginator.pages| default(value=cur_section.pages) %}
|
||||
{% for page in pages %}
|
||||
<article>
|
||||
<div>
|
||||
<a class="u-url" href="{{ page.permalink }}"><h2>{{ page.title }}</h2></a>
|
||||
{%- if page.date -%}<time class="dt-published" datetime="{{ page.date }}">📅 {{ page.date | date(format=trans(key="dateFormat", lang=lang)) }}</time>{%- endif -%}
|
||||
</div>
|
||||
{% if page.summary %}
|
||||
<div class="p-summary e-content">
|
||||
{{ page.summary | markdown | safe }}
|
||||
<a class="read-more" href="{{ page.permalink }}">--> {{ trans(key="readmore", lang=lang) }} <--</a>
|
||||
</div>
|
||||
{% elif full_articles %}
|
||||
<div class="e-content">
|
||||
{{ page.content | markdown | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% if cur_paginator and cur_paginator.number_pagers > 1 %}
|
||||
<aside class="pagination">
|
||||
{% if cur_paginator.previous %}
|
||||
<a href="{{ cur_paginator.previous }}"><-- {{ trans(key="previousPage", lang=lang) }}</a>
|
||||
{% endif %}
|
||||
{% if cur_paginator.next %}
|
||||
<a href="{{ cur_paginator.next }}">{{ trans(key="nextPage", lang=lang) }} --></a>
|
||||
{% endif %}
|
||||
</aside>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endmacro section %}
|
||||
|
|
11
theme.toml
11
theme.toml
|
@ -24,6 +24,17 @@ max_width_for = "main" # Can be either main or body
|
|||
# setting. 800px is the water.css default
|
||||
max_width = "800px"
|
||||
|
||||
# If home_section is empty, homepage is generated from the content of the index
|
||||
# page content/_index*.md. If you want to display a section's latest articles on
|
||||
# the homepage, set home_section to the name of this section without _index.md,
|
||||
# like "blog" for content/blog/. Pagination is defined by this section's
|
||||
# pagination settings.
|
||||
home_section = ""
|
||||
# Determines whether to show full articles on the homepage. If disabled, it will
|
||||
# only show summaries (if they are defined in the content), or the date/title.
|
||||
home_fullarticles = true
|
||||
|
||||
|
||||
# The settings below point to a markdown page in content/,
|
||||
# without the "content/" in the path. Additionally, the page
|
||||
# will be translated in the current language. Use "disabled"
|
||||
|
|
Loading…
Reference in New Issue