Skip to content

Commit 0d385a9

Browse files
ramgopalsiddhindiVar0508
authored andcommitted
Refactor archive and author layouts for improved post filtering; update community blog and index to exclude community posts from general listings.
1 parent 6bf3093 commit 0d385a9

6 files changed

Lines changed: 22 additions & 28 deletions

File tree

_config.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ plugins:
2020

2121
# Archives
2222
jekyll-archives:
23-
enabled: all
23+
enabled:
24+
- categories
25+
- years
26+
- months
27+
- days
2428
layout: archive
2529
permalinks:
2630
category: '/archives/:name/'
@@ -33,9 +37,6 @@ collections:
3337
authors:
3438
output: true
3539
permalink: /authors/:path/
36-
community:
37-
output: true
38-
permalink: /community-blog/:title/
3940

4041
defaults:
4142
- scope:
@@ -45,11 +46,10 @@ defaults:
4546
layout: "archive"
4647
type: "authors"
4748
- scope:
48-
path: ""
49-
type: "community"
49+
path: "_posts/community"
5050
values:
5151
layout: "post"
52-
type: "community"
52+
permalink: /community-blog/:title/
5353

5454
# Pagination
5555
paginate: 6

_layouts/archive.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ <h2>Archive of posts {% if page.type == "year" %} during {{ page.type }} {% elsi
1111
</div>
1212
<div class="row listrecent">
1313
{% if page.type == "authors" %}
14-
{% for post in site.posts %}
15-
{% if post.authors contains page.username or page.username == post.authors %}
16-
{% include postbox.html %}
17-
{% endif %}
14+
{% assign author_posts = site.posts | where_exp: "post", "post.authors contains page.username or page.username == post.authors" %}
15+
{% for post in author_posts %}
16+
{% include postbox.html %}
1817
{% endfor %}
1918
{% else %}
20-
{% for post in page.posts %}
21-
{% include postbox.html %}
22-
{% endfor %}
19+
{% for post in page.posts %}
20+
{% include postbox.html %}
21+
{% endfor %}
2322
{% endif %}
2423
</div>
2524
</section>
26-

authors.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@
2121
</span>
2222
<span class="author-meta">
2323
<span class="post-name"><a href="{{author.url}}">{{ author.name }}</a></span><br/>
24-
{% assign number_of_posts = 0 %}
25-
{% for post in site.posts %}
26-
{% if post.authors contains author.username or author.username == post.authors %}
27-
{% assign number_of_posts = number_of_posts | plus: 1 %}
28-
{% endif %}
29-
{% endfor %}
30-
<span class="post-date">Posts contributed: {{ number_of_posts }}</span>
24+
{% assign author_posts = site.posts | where_exp: "doc", "doc.authors contains author.username or author.username == doc.authors" %}
25+
<span class="post-date">Posts contributed: {{ author_posts.size }}</span>
3126
</span>
3227
<span class="post-read-more"><a href="{{author.url}}" title="Read Story"><svg class="svgIcon-use" width="25" height="25" viewbox="0 0 25 25"><path d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z" fill-rule="evenodd"></path></svg></a></span>
3328
<div class="clearfix"></div>

blog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<div class="col-lg-12 col-md-12 mb-30px">
1414
{% for post in site.posts %}
15+
{% if post.categories contains 'community' %}{% continue %}{% endif %}
1516
{% assign currentDate = post.date | date: "%Y" %}
1617
{% if currentDate != myDate %}
1718
{% unless forloop.first %}</ul>{% endunless %}

community-blog.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
<div class="row listrecent">
1313

1414
<div class="col-lg-12 col-md-12 mb-30px">
15-
{% assign community_posts = site.community %}
16-
{% assign sorted_posts = community_posts | reverse %}
17-
{% for post in sorted_posts %}
15+
{% assign community_posts = site.posts | where: "categories", "community" %}
16+
{% for post in community_posts %}
1817
{% assign currentDate = post.date | date: "%Y" %}
1918
{% if currentDate != myDate %}
2019
{% unless forloop.first %}</ul>{% endunless %}

index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ <h2 class="exclusive-tabs-header">
3838
<div id="area-meetup" class="exclusive-pane">
3939
<div class="row listrecent">
4040
{% for post in paginator.posts %}
41+
{% if post.categories contains 'community' %}{% continue %}{% endif %}
4142
{% include postbox.html %}
4243
{% endfor %}
4344
</div>
@@ -53,9 +54,9 @@ <h2 class="exclusive-tabs-header">
5354
<!-- Community Blog Pane -->
5455
<div id="area-community" class="exclusive-pane">
5556
<div id="community-posts-container" class="row listrecent">
56-
{% if site.community.size > 0 %}
57-
{% assign sorted_community = site.community | reverse %}
58-
{% for post in sorted_community %}
57+
{% assign community_posts = site.posts | where: "categories", "community" %}
58+
{% if community_posts.size > 0 %}
59+
{% for post in community_posts %}
5960
{% include postbox.html %}
6061
{% endfor %}
6162
{% else %}

0 commit comments

Comments
 (0)