blob: e078bdd33f15af0c8920f0aedf0b27663d6c9480 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
{#
This Template Shows the Posts Grouped by Year: example.com/archive/
This Template can also be used as the rendering template for Sections, eg: example.com/blog/ example.com/software/
#}
{% extends "base.html" %}
{%- set uglyurls = config.extra.uglyurls | default(value=false) -%}
{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %}
{%- block seo %}
{{- super() }}
{%- set title = "Archive" %}
{%- if config.title %}
{%- set title_addition = title_separator ~ config.title %}
{%- else %}
{%- set title_addition = "" %}
{%- endif %}
{%- set description = config.description %}
{{- macros_seo::seo(config=config, title=title, title_addition=title_addition, description=description, is_home=true) }}
{%- endblock seo %}
{%- block content %}
{#- The following line is checking if the template is being used for the archive page or a section #}
{%- if current_path is matching("^(/[[:alpha:]][[:alpha:]])?/archive/$") %}
{%- if section.extra.sec %}
{%- set sec = section.extra.sec ~ "/" %}
{%- else %}
{%- set sec = "" %}
{%- endif %}
{%- else %}
{%- set langpath = "/" %}
{%- if lang != config.default_language %}
{%- set langpath = "/" ~ lang ~ "/" %}
{%- endif %}
{%- set sec = current_path | trim_start_matches(pat=langpath) | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %}
{%- set sec = sec ~ "/" %}
{%- endif %}
{%- if lang == config.default_language %}
{%- set section_item = get_section(path=sec ~ "_index.md") %}
{%- else %}
{%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %}
{%- endif %}
{%- if sec != "" %}
{#- the section always overrides the config -#}
{%- if section_item.extra and 'hide_section_dates' in section_item.extra -%}
{%- set hide_section_dates = section_item.extra.hide_section_dates -%}
{%- elif config.extra.hide_section_dates -%}
{%- set hide_section_dates = true -%}
{%- endif -%}
{%- endif %}
<div>
{%- if section_item.title %}
<h2>{{ section_item.title }}</h2>
{%- endif %}
{{- section_item.content | safe }}
{%- if config.extra.archive_reverse %}
{%- for year, posts in section_item.pages | sort(attribute="year") | reverse | group_by(attribute="year") %}
{%- if not hide_section_dates %}
{%- if section_item.title %}
<h3>{{ year }}</h3>
{%- else %}
<h2>{{ year }}</h2>
{%- endif %}
{%- endif %}
{%- for post in posts %}
<p><a href="{{ post.permalink | safe }}{%- if uglyurls %}index.html{%- endif %}">{{ post.title }}</a>{%- if not hide_section_dates %} - <time datetime="{{ post.date }}">{{ post.date | date(format="%F") }}</time>{%- endif %}</p>
{%- endfor %}
{%- endfor %}
{%- else %}
{%- for year, posts in section_item.pages | group_by(attribute="year") %}
{%- if not hide_section_dates %}
{%- if section_item.title %}
<h3>{{ year }}</h3>
{%- else %}
<h2>{{ year }}</h2>
{%- endif %}
{%- endif %}
{%- for post in posts %}
<p><a href="{{ post.permalink | safe }}{%- if uglyurls %}index.html{%- endif %}">{{ post.title }}</a>{%- if not hide_section_dates %} - <time datetime="{{ post.date }}">{{ post.date | date(format="%F") }}</time>{%- endif %}</p>
{%- endfor %}
{%- endfor %}
{%- endif %}
</div>
{%- endblock content %}
|