Skip to content

Commit 2640ebc

Browse files
committed
adding date posts
1 parent 3b062ae commit 2640ebc

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Changes made to fulfil my needs:
123123
* Added [PDF viewer](https://github.com/alesordo/alesordo.github.io)
124124
* Added scss and modified ```portfolYOU.scss```
125125
* Customized landing page with dynamic message
126+
* Added date dropdown page to list posts in blog
126127

127128
<div align="center">
128129
<sub><sup>© 2025 Alejandro Garnung Menéndez, licensed under the <a href="./LICENSE">MIT License</a>.</sup></sub>

_includes/blog/calendar.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- Group posts by date -->
2+
{%- assign posts_by_date = {} -%}
3+
{%- for post in site.posts -%}
4+
{%- assign post_date = post.date | date: "%Y-%m" -%} <!-- Group by year and month -->
5+
{%- if posts_by_date[post_date] == nil -%}
6+
{%- assign posts_by_date[post_date] = "" -%}
7+
{%- endif -%}
8+
{%- assign posts_by_date[post_date] = posts_by_date[post_date] | append: post.url | append: "|" -%}
9+
{%- endfor -%}
10+
11+
<!-- Create a dropdown list by date -->
12+
{% for date, posts in posts_by_date %}
13+
<div class="py-3">
14+
<h4 id="{{ date }}">{{ date }}</h4>
15+
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#posts-{{ date }}" aria-expanded="false" aria-controls="posts-{{ date }}">
16+
Ver posts
17+
</button>
18+
<div class="collapse" id="posts-{{ date }}">
19+
<ol>
20+
{% assign post_urls = posts | split: '|' %}
21+
{% for post_url in post_urls %}
22+
{%- assign post = site.posts | where: "url", post_url | first -%}
23+
<li><a href="{{ post.url | relative_url }}">{{ post.title }}</a></li>
24+
<small class="text-muted"> - {{ post.date | date_to_long_string }}</small>
25+
<br/>
26+
{% endfor %}
27+
</ol>
28+
</div>
29+
</div>
30+
<hr class="bg-light">
31+
{% endfor %}

_includes/blog/search.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<i class="fas fa-search"></i>
88
</span>
99
</div>
10+
<button class="btn btn-outline-primary ml-1" onclick="location.href = '{{ '/blog/calendar' | relative_url }}';">
11+
<i class="fas fa-calendar"></i>
12+
</button>
1013
<button class="btn btn-outline-primary ml-1" onclick="location.href = '{{ '/blog/tags' | relative_url }}';">
1114
<i class="fas fa-tags"></i>
1215
</button>

0 commit comments

Comments
 (0)