You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DjangoBlog-Maintenance-Anal.../DjangoBlog/templates/blog/article_archives.html

64 lines
3.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{% extends 'share_layout/base.html' %} {# 继承基础模板,复用基础模板的结构和样式 #}
{% load blog_tags %} {# 加载自定义的blog_tags模板标签库以便使用其中的模板标签 #}
{% load cache %} {# 加载缓存模板标签库,用于缓存部分页面内容 #}
{% load i18n %} {# 加载国际化模板标签库,支持多语言翻译 #}
{% block header %} {# 定义页面头部的block用于填充页面头部相关内容 #}
<title>{% trans 'article archive' %} | {{ SITE_DESCRIPTION }}</title>
{# 设置页面标题,使用国际化翻译显示“文章归档”,并拼接站点描述 #}
<meta name="description" content="{{ SITE_SEO_DESCRIPTION }}"/>
<meta name="keywords" content="{{ SITE_KEYWORDS }}"/> {# 设置页面描述元数据 #}
<meta property="og:type" content="blog"/>
<meta property="og:title" content="{{ SITE_NAME }}"/>
<meta property="og:description" content="{{ SITE_DESCRIPTION }}"/>
<meta property="og:url" content="{{ SITE_BASE_URL }}"/>
<meta property="og:site_name" content="{{ SITE_NAME }}"/>
{% endblock %}
{% block content %} {# 定义页面主要内容的block #}
<div id="primary" class="site-content"> {# 主要内容的外层容器设置id和class用于样式控制 #}
<div id="content" role="main"> {# 主要内容区域role属性表明其主要内容的角色 #}
<header class="archive-header"> {# 文章归档部分的头部容器 #}
<p class="archive-title">{% trans 'article archive' %}</p> {# 显示“文章归档”的标题 #}
</header><!-- .archive-header -->
<div class="entry-content"> {# 文章归档的内容区域 #}
{% regroup article_list by pub_time.year as year_post_group %} {# 将文章列表按发布时间的年份分组结果保存到year_post_group #}
<ul>
{% for year in year_post_group %}
{# 遍历按年份分组的结果 #}
<li>{{ year.grouper }} {% trans 'year' %} {# 显示年份 #}
{% regroup year.list by pub_time.month as month_post_group %}
<ul>
{% for month in month_post_group %} {# 遍历按月份分组的结果 #}
<li>{{ month.grouper }} {% trans 'month' %}
{# 显示月份,以及“月”的国际化翻译 #}
<ul>
{% for article in month.list %}
<li><a href="{{ article.get_absolute_url }}">{{ article.title }}</a>
</li> {# 显示文章标题,并设置链接到文章详情页 #}
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
</div><!-- #content -->
</div><!-- #primary -->
{% endblock %}
{% block sidebar %}
{% load_sidebar user 'i' %}
{% endblock %}