Skip to content

Commit

Permalink
Add support for image previews in collections
Browse files Browse the repository at this point in the history
  • Loading branch information
minkezhang committed Nov 26, 2024
1 parent cfb81ef commit b032bc3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion _includes/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
-->
<div class="tile">

{% if p.image %}
{% if p.image_small %}
<a href="{{ p.url | relative_url }}" class="post-image-link">
<img src="{{ p.image_small }}" />
</a>
{% eslif if p.image %}
<a href="{{ p.url | relative_url }}" class="post-image-link">
<img src="{{ p.image }}" />
</a>
Expand Down
1 change: 1 addition & 0 deletions _plugins/relative_link_filter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO(minkezhang): Replace with modified
# https://github.com/rukbotto/jekyll-absolute-links instead to handle more edge
# cases, e.g. embedded code exceptions.

module Jekyll
module RelativeLinkFilter
# Replace relative links e.g. "path/to/x" to "/absolute/path/to/x" in input
Expand Down
1 change: 1 addition & 0 deletions _posts/2021-02-12-features/2021-02-12-features.md.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
layout: post
image_small: https://www.screensaversplanet.com/img/screenshots/screensavers/large/nyan-cat-2.png
image: https://raw.githubusercontent.com/Gowee/nyancat-svg/main/nyancat.svg

tags: ["features"]
Expand Down
3 changes: 2 additions & 1 deletion _posts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ redirect_to:
- /path/to/new/link.html

# Custom fields.
author: key # References site.data.authors.
author: key # References site.data.authors.
image_small: url # Optionally used for collections.
image: url
preview: >-
Manually written excerpt of the content.
Expand Down

0 comments on commit b032bc3

Please sign in to comment.