Skip to content

Commit

Permalink
enable blog to redirect to asset (alshedivat#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnut1648 authored and horaciochacon committed Feb 28, 2023
1 parent ef5aeb5 commit f13e5f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions _posts/2022-02-01-redirect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: post
title: a post with redirect
date: 2021-07-04 17:39:00
description: you can also redirect to assets like pdf
redirect: /assets/pdf/example_pdf.pdf
---
7 changes: 6 additions & 1 deletion blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ <h2>{{ site.blog_description }}</h2>
{% assign categories = post.categories | join: "" %}

<li>
<h3><a class="post-title" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
<h3>
{% if post.redirect == blank %}
<a class="post-title" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
{% else %}
<a class="post-title" href="{% if post.redirect contains '://' %}{{ post.redirect }}{% else %}{{ post.redirect | relative_url }}{% endif %}">{{ post.title }}</a>
{% endif %}
</h3>
<p>{{ post.description }}</p>
<p class="post-meta"> {{read_time}} min read &nbsp; &middot; &nbsp;
Expand Down

0 comments on commit f13e5f4

Please sign in to comment.