Skip to content

Commit

Permalink
Feature: add an option for generating excerpt automatically. #178
Browse files Browse the repository at this point in the history
  • Loading branch information
iissnan committed Jul 13, 2015
1 parent a26a93b commit 6a9968c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 4 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org
# editorconfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
[*.py]
indent_size = 4
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ scroll_to_more: true
# Automatically add list number to toc.
toc_list_number: true

# Automatically Excerpt
auto_excerpt:
enable: false
length: 150

# Use Lato font
# Note: this option is avialable only when the language is not `zh-Hans`
Expand Down
6 changes: 4 additions & 2 deletions layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@
{{ __('post.read_more') }} »
</a>
</div>
{% elif post.excerpt %}
{% elif post.excerpt %}
{{ post.excerpt }}
<div class="post-more-link text-center">
<a class="btn" href="{{ url_for(post.path) }}{% if theme.scroll_to_more %}#more{% endif %}" rel="contents">
{{ __('post.read_more') }} &raquo;
</a>
</div>
{% elif theme.auto_excerpt.enable %}
<span itemprop="articleBody">{{ post.content | striptags | truncate(theme.auto_excerpt.length) }}</span>
{% else %}
<span itemprop="articleBody">{{ post.content }}</span>
<span itemprop="articleBody">{{ post.content }}</span>
{% endif %}
{% else %}
<span itemprop="articleBody">{{ post.content }}</span>
Expand Down

0 comments on commit 6a9968c

Please sign in to comment.