Skip to content

Commit

Permalink
pages: configuration option to display either post content, post summ…
Browse files Browse the repository at this point in the history
…ary or custom format
  • Loading branch information
mplx committed Sep 23, 2016
1 parent 9d05e9a commit ecdfde1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions hpstr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ enabled: true
color: blue
dropdown:
enabled: false
pages:
display: content # content, summary, custom
18 changes: 13 additions & 5 deletions templates/page.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% embed 'partials/base.html.twig' %}

{% set collection = page.collection() %}
{% set base_url = page.url %}
{% set collection = page.collection() %}
{% set base_url = page.url %}
{% set feed_url = base_url %}

{% if base_url == '/' %}
Expand All @@ -12,7 +12,7 @@
{% set feed_url = base_url~'/'~page.slug %}
{% endif %}

{% block content %}
{% block content %}

{% for post in collection %}
<article class="hentry">
Expand All @@ -33,7 +33,15 @@
{% endif %}
</header>
<div class="entry-content">
{{ post.summary }}
{% if grav.theme.config.pages.display == 'content' %}
{{ post.content }}
{% elseif grav.theme.config.pages.display == 'summary' %}
{{ post.summary }}
{% elseif grav.theme.config.pages.display == 'custom' %}
{% include 'partials/pages-displaytext.html.twig' %}
{% else %}
{{ post.summary }}
{% endif %}
</div><!-- /.entry-content -->
</article><!-- /.hentry -->
{% endfor %}
Expand All @@ -42,7 +50,7 @@
{% include 'partials/pagination.html.twig' with {'pagination':collection.params.pagination} %}
{% endif %}

{% endblock %}
{% endblock %}

{% endembed %}

Expand Down
7 changes: 7 additions & 0 deletions templates/partials/pages-displaytext.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if post.summary == post.content %}
{{ post.content }}
{% else %}
{{ post.summary }}
<br>
<a href="{{ post.url }}" title="{{ post.title }}" class="btn btn-primary">Continue reading</a>
{% endif %}

0 comments on commit ecdfde1

Please sign in to comment.