mirror of
https://github.com/metagov/govarch-website.git
synced 2025-06-18 17:14:15 +00:00
allow user to disable truncating excerpts and add excerpts to readme
This commit is contained in:
37
README.md
37
README.md
@ -51,7 +51,7 @@ To include navigation in your site's masthead:
|
|||||||
|
|
||||||
Be sure to start your `url`s with a `/`.
|
Be sure to start your `url`s with a `/`.
|
||||||
|
|
||||||
## Pagination
|
#### Pagination
|
||||||
|
|
||||||
To paginate your posts, add the following line to your site's `Gemfile`:
|
To paginate your posts, add the following line to your site's `Gemfile`:
|
||||||
|
|
||||||
@ -71,6 +71,41 @@ paginate_path: "/page/:num/"
|
|||||||
|
|
||||||
You can set the `paginate` and `paginate_path` settings to whatever best suits you.
|
You can set the `paginate` and `paginate_path` settings to whatever best suits you.
|
||||||
|
|
||||||
|
#### Excerpts
|
||||||
|
|
||||||
|
To show [excerpts](https://jekyllrb.com/docs/posts/#post-excerpts) of your blog posts on the home page, add the following settings to your site's `_config.yml` file:
|
||||||
|
|
||||||
|
```
|
||||||
|
show_excerpts: true
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, excerpts that have more than 140 characters will be truncated to 20 words. In order to override the number of words you'd like to show for your excerpts, add the following setting to your site's `_config.yml` file:
|
||||||
|
|
||||||
|
```
|
||||||
|
excerpt_length: 20
|
||||||
|
```
|
||||||
|
|
||||||
|
To disable excerpt truncation entirely, simply set `excerpt_length` to `0` in your site's `_config.yml` file, like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
excerpt_length: 0
|
||||||
|
```
|
||||||
|
|
||||||
|
If you do this, the theme will still respect Jekyll's `excerpt_separator` feature as [described in the Jekyll documentation](https://jekyllrb.com/docs/posts/#post-excerpts).
|
||||||
|
|
||||||
|
|
||||||
|
#### Title-less Posts
|
||||||
|
|
||||||
|
If you want to publish posts that don't have a title, add the following setting to the [front matter](https://jekyllrb.com/docs/frontmatter/) of the post:
|
||||||
|
|
||||||
|
```
|
||||||
|
title: ""
|
||||||
|
```
|
||||||
|
|
||||||
|
When you do this, the home page will display a truncated [excerpt](https://jekyllrb.com/docs/posts/#post-excerpts) of the first paragraph of your post.
|
||||||
|
|
||||||
|
Note that setting `excerpt_length` in your site's `_config.yml` file will set the length of _all_ excerpts, regardless of whether the post has a title or not. For posts with a title, the excerpt will appear under the title and slightly lighter. For title-less posts, the excerpt will appear as if it were a title.
|
||||||
|
|
||||||
### Post Layout
|
### Post Layout
|
||||||
|
|
||||||
A sparsely decorated layout designed to present long-form writing in a manner that's pleasing to read.
|
A sparsely decorated layout designed to present long-form writing in a manner that's pleasing to read.
|
||||||
|
@ -37,4 +37,5 @@ markdown: kramdown
|
|||||||
# - vendor/gems/
|
# - vendor/gems/
|
||||||
# - vendor/ruby/
|
# - vendor/ruby/
|
||||||
|
|
||||||
show_excerpts: true
|
show_excerpts: true
|
||||||
|
excerpt_length: 0
|
@ -2,12 +2,18 @@
|
|||||||
{{ post.excerpt | replace: "<p>", "" | replace: "</p>", "" }}
|
{{ post.excerpt | replace: "<p>", "" | replace: "</p>", "" }}
|
||||||
{% endcapture %}
|
{% endcapture %}
|
||||||
|
|
||||||
{% assign excerpt_length = excerpt | size %}
|
{% if site.excerpt_length %}
|
||||||
|
{% assign excerpt_length = site.excerpt_length %}
|
||||||
|
{% else %}
|
||||||
|
{% assign excerpt_length = 20 %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<em class="post-link__excerpt">
|
{% assign excerpt_size = excerpt | size %}
|
||||||
{% if excerpt_length > 140 %}
|
|
||||||
{{ excerpt | truncatewords: 20, '…' }}
|
<span class="post-link__excerpt">
|
||||||
|
{% if excerpt_size > 140 and excerpt_length > 0 %}
|
||||||
|
{{ excerpt | truncatewords: excerpt_length, '…' }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ excerpt }}
|
{{ excerpt }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</em>
|
</span>
|
Reference in New Issue
Block a user