Skip to content

Commit 46d9b82

Browse files
fix: make posts clickable on the main page
1 parent 69077f0 commit 46d9b82

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

templates/index.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ <h2>Recent Posts</h2>
44
<ul>
55
{% for post in posts %}
66
<li>
7-
{% if post.content_type == "Post" %}
8-
{% include "partial/post.html" %}
9-
{% elif post.content_type == "Link" %}
10-
{% include "partial/link.html" %}
7+
{% if post.content_type == "Link" %}
8+
{% include "partial/link.html" %}
9+
<p><a href="/post/{{ post.id }}">Permalink</a></p>
10+
{% elif post.content_type == "Post" %}
11+
{% set is_index = true %}
12+
{% include "partial/post.html" %}
1113
{% elif post.content_type == "Quote" %}
12-
{% include "partial/quote.html" %}
14+
{% include "partial/quote.html" %}
15+
<p><a href="/post/{{ post.id }}">Permalink</a></p>
1316
{% endif %}
1417
</li>
1518
{% endfor %}

templates/partial/post.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<article>
2+
{% if is_index %}
3+
<h1><a href="/post/{{ post.id }}">{{ post.title }}</a></h1>
4+
{% else %}
25
<h1>{{ post.title }}</h1>
6+
{% endif %}
37
<p><small>Published on {{ post.date }}</small></p>
48
<div>{{ post.content|safe }}</div>
59
</article>

templates/post.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
{% extends "base.html" %} {% block content %}
2-
<main>{% include "partial/post.html" %}</main>
2+
<main>
3+
{% if post.content_type == "Post" %}
4+
{% include "partial/post.html" %}
5+
{% elif post.content_type == "Link" %}
6+
{% include "partial/link.html" %}
7+
{% elif post.content_type == "Quote" %}
8+
{% include "partial/quote.html" %}
9+
{% endif %}
10+
</main>
311
{% include "partial/commits.html" %} {% endblock %}

0 commit comments

Comments
 (0)