Skip to content

Commit

Permalink
Index displays categories, more link
Browse files Browse the repository at this point in the history
  • Loading branch information
fongandrew committed Jun 1, 2017
1 parent c699790 commit 49cd431
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,63 @@
{% for post in paginator.posts %}
<div class="post">
<h1 class="post-title">
<a href="{{ post.url }}">
<a href="{{ site.baseurl }}{{ post.url }}">
{{ post.title }}
</a>
</h1>

<span class="post-date">{{ post.date | date_to_string }}</span>
<div class="post-meta">
<span class="post-date">{{ post.date | date_to_string }}</span>
<span class="post-categories">
{% for category in post.categories %}
&bull;

{% comment %}
Check if this category has a corresponding page before decide
to link to it. This is an O(n^2) operations so consider removing
it and linking for all categories (or no categories) if this
site has a lot of pages and/or a lot of categories.
{% endcomment %}
{% assign category_page = false %}
{% for node in site.pages %}
{{ node.category }}
{% if node.category == category or node.title == category %}
{% assign category_page = node %}
{% endif %}
{% endfor %}

{% if category_page %}
<a href="{{ site.baseurl }}{{ category_page.url }}">
{{ category }}
</a>
{% else %}
{{ category }}
{% endif %}
{% endfor %}
</span>
</div>

{% if post.excerpt %}
{{ post.excerpt }}
{% else %}
{{ post.content }}
{% endif %}



{% if post.excerpt %}
{% comment %}Excerpt may be equal to content. Check.{% endcomment %}
{% capture content_words %}
{{ post.content | number_of_words }}
{% endcapture %}
{% capture excerpt_words %}
{{ post.excerpt | number_of_words }}
{% endcapture %}

{% if content_words != excerpt_words %}
<a href="{{ site.baseurl }}{{ post.url }}">More &hellip;</a>
{% endif %}
{% endif %}
</div>
{% endfor %}
</div>
Expand Down

0 comments on commit 49cd431

Please sign in to comment.