Pelican 中类别的介绍页面
Introduction pages for categories in Pelican
我想在 Pelican 中构建我的个人网页,但我缺少一项功能。我很想为页面上的 some/all 个类别提供一个 介绍页面 。
例如 - 我想为我的资助项目建立一个页面,其中的帖子与活动相关 and/or 发表的论文,但是 我也想要单个 页 说一些关于赠款项目的事情,并将此页面保留为该类别的标题页。
在 Pelican 框架中这可能(很容易)吗?如果没有,你能推荐更好的静态页面框架,结合 Markdown+Python?
用 pelican 实际上这很容易。插件 Auto Pages 定义了三个额外的内容文件夹:一个用于作者,一个用于类别,一个用于标签。
假设您,John Smith,希望在点击您的名字时获得关于您的人的额外信息。然后,您将使用这些额外信息添加一个名为 authors/john-smith{.rst|.md}
的文件。没有HTML,只有你想提供的关于你的人的内容。然后将这些内容读入、转换并作为 author.page
.
呈现给模板引擎
现在是关于您的模板也使用这个变量。
在我的主题中,我简单地修改了 theme/templates/author.html
不显示与我作者相关的 "featured article" 和 "other articles" 的组合,而是显示与我相关的 author.page.content
和 "all articles"我的作者。
我的 theme/templates/author.html
的简短摘录:
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a></h1>
{{ author.page.content }}
</article>
</aside>
<section id="content" class="body">
<!-- removed the apostrophe for SO highlighting reasons-->
<h1>Authors articles</h1>
<hr/>
<ol id="posts-list" class="hfeed" start="{{ articles_paginator.per_page - 1}}">
{% for article in articles_page.object_list %}
<li><article class="hentry">
<header>
<h1><a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark"
title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h1>
</header>
{% include 'article_infos.html' %}
{{ article.summary }}
<a class="readmore" href="{{ SITEURL }}/{{ article.url }}">read more</a>
{% include 'comments.html' %}
</article></li>
{% endfor %}
</ol>
{% if articles_page.has_other_pages() %}
{% include 'pagination.html' %}
{% endif %}
</section>
您可以使用上述过程对类别和标签执行完全相同的操作。对于模板,只需使用现有的 index.html
并根据您的需要进行调整。
我想在 Pelican 中构建我的个人网页,但我缺少一项功能。我很想为页面上的 some/all 个类别提供一个 介绍页面 。
例如 - 我想为我的资助项目建立一个页面,其中的帖子与活动相关 and/or 发表的论文,但是 我也想要单个 页 说一些关于赠款项目的事情,并将此页面保留为该类别的标题页。
在 Pelican 框架中这可能(很容易)吗?如果没有,你能推荐更好的静态页面框架,结合 Markdown+Python?
用 pelican 实际上这很容易。插件 Auto Pages 定义了三个额外的内容文件夹:一个用于作者,一个用于类别,一个用于标签。
假设您,John Smith,希望在点击您的名字时获得关于您的人的额外信息。然后,您将使用这些额外信息添加一个名为 authors/john-smith{.rst|.md}
的文件。没有HTML,只有你想提供的关于你的人的内容。然后将这些内容读入、转换并作为 author.page
.
现在是关于您的模板也使用这个变量。
在我的主题中,我简单地修改了 theme/templates/author.html
不显示与我作者相关的 "featured article" 和 "other articles" 的组合,而是显示与我相关的 author.page.content
和 "all articles"我的作者。
我的 theme/templates/author.html
的简短摘录:
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a></h1>
{{ author.page.content }}
</article>
</aside>
<section id="content" class="body">
<!-- removed the apostrophe for SO highlighting reasons-->
<h1>Authors articles</h1>
<hr/>
<ol id="posts-list" class="hfeed" start="{{ articles_paginator.per_page - 1}}">
{% for article in articles_page.object_list %}
<li><article class="hentry">
<header>
<h1><a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark"
title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h1>
</header>
{% include 'article_infos.html' %}
{{ article.summary }}
<a class="readmore" href="{{ SITEURL }}/{{ article.url }}">read more</a>
{% include 'comments.html' %}
</article></li>
{% endfor %}
</ol>
{% if articles_page.has_other_pages() %}
{% include 'pagination.html' %}
{% endif %}
</section>
您可以使用上述过程对类别和标签执行完全相同的操作。对于模板,只需使用现有的 index.html
并根据您的需要进行调整。