Display an index page below the articles without abstract
This commit is contained in:
parent
ffe246033e
commit
4f354c0014
6 changed files with 38 additions and 24 deletions
|
@ -10,7 +10,7 @@ IGNORED_PATHS = [
|
|||
def pages(request):
|
||||
if request.path in IGNORED_PATHS:
|
||||
return {}
|
||||
return {"pages": Page.objects.filter(status=Article.PUBLISHED)}
|
||||
return {"pages": Page.objects.filter(status=Article.PUBLISHED).exclude(position=0)}
|
||||
|
||||
|
||||
def drafts_count(request):
|
||||
|
|
|
@ -48,6 +48,10 @@ a {
|
|||
border-bottom: .3ex solid var(--accent);
|
||||
}
|
||||
|
||||
.index-page h2 {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.article-list h2 a {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{% extends 'articles/base.html' %}
|
||||
|
||||
{% block title %}
|
||||
{{ article.title }}
|
||||
{% endblock %}
|
||||
{% block title %}{{ article.title }} | {% endblock %}
|
||||
{% block content %}
|
||||
<article class="article-detail">
|
||||
<h1>{{ article.title }}{% if article.status != article.PUBLISHED %}
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
{% extends 'articles/base.html' %}
|
||||
|
||||
{% block title %}
|
||||
{{ title_header }}
|
||||
{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
{% block content %}
|
||||
<h1>{{ blog_title }}{% if title %} · {{ title }}{% endif %}</h1>
|
||||
<p class="metadata">{{ blog_description }}</p>
|
||||
<ul>
|
||||
{% for article in articles %}
|
||||
<li>
|
||||
{% if article.published_at %}
|
||||
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
|
||||
{% else %}
|
||||
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
|
||||
{% endif %}
|
||||
: <a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li>No article here. Come back later 🙂</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<p class="metadata">{{ blog_description }} {% include "articles/admin_link_snippet.html" %}</p>
|
||||
<section class="blog-posts">
|
||||
<h2>Blog posts</h2>
|
||||
<ul>
|
||||
{% for article in articles %}
|
||||
<li>
|
||||
{% if article.published_at %}
|
||||
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
|
||||
{% else %}
|
||||
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
|
||||
{% endif %}
|
||||
: <a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li>No article here. Come back later 🙂</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
<nav class="pagination">
|
||||
<div class="older">
|
||||
{% if page_obj.has_next %}
|
||||
|
@ -32,4 +33,10 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
<section class="index-page">
|
||||
<h2>{{ index_page.title }}</h2>
|
||||
<div>
|
||||
{{ index_page.get_formatted_content|safe }}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}Home{% endblock %} | Gab's Notes</title>
|
||||
<title>{% block title %}Home | {% endblock %}Gab's Notes</title>
|
||||
<link rel="stylesheet" id="code-light" href="{% static 'code-light.css' %}" type="text/css">
|
||||
<link rel="stylesheet" id="code-dark" href="{% static 'code-dark.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'style.css' %}" type="text/css">
|
||||
|
|
|
@ -9,6 +9,8 @@ from articles.models import Article, Page
|
|||
|
||||
|
||||
class BaseArticleListView(generic.ListView):
|
||||
paginate_by = 10
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["blog_title"] = settings.BLOG["title"]
|
||||
|
@ -23,7 +25,10 @@ class ArticlesListView(BaseArticleListView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["title_header"] = "Articles"
|
||||
index_page = Page.objects.filter(
|
||||
status=Article.PUBLISHED, position=0
|
||||
).first() # type: Page
|
||||
context["index_page"] = index_page
|
||||
return context
|
||||
|
||||
|
||||
|
|
Reference in a new issue