ABlog 配置选项

此帖子描述了 ABlog 的配置选项,这些选项在 Sphinx 构建配置文件 中。

通用选项

blog_path

一个相对于博客档案页配置目录的路径。默认为 'blog'

blog_title

博客的“标题”,在 acthive 页面中使用。默认是 'Blog'

blog_baseurl

网站的基本 URL,生成 feeds 时需要。

blog_archive_titles

选择只对收藏页中的帖子标题进行存档,默认为 False

作者、语言及地点

blog_authors

一个作者名字的字典,映射到作者的完整显示名称和链接。字典中的键是应该在 post 指令中用来指代作者的。默认是 {}。例如

blog_authors = {
    'Ahmet': ('Ahmet Bakan', 'http://ahmetbakan.com'),
    'Durden': ('Tyler Durden',
               'https://en.wikipedia.org/wiki/Tyler_Durden'),
}
blog_languages

语言代码名称的字典,映射到这些语言的完整显示名称和链接。类似于 blog_authors,字典的键应该在 post 指令中使用,以指代这些位置。默认是 {}。例如

blog_languages = {
    'en': ('English', None),
}
blog_locations

一个位置名称的字典,映射到这些位置的完整显示名称和链接。类似于 blog_authors,字典中的键应该在 post 指令中使用,以引用位置。默认是 {}

blog_default_author

blog_authors 中定义的默认作者的名字。默认为 None

blog_default_language

blog_languages 中定义的默认语言的代码名称。默认为 None

blog_default_location

blog_locations 中定义的默认位置的名称。默认为 None

Updated on Mon Sep 15 00:00:00 2014

增加了 blog_languagesblog_default_language 配置变量。

帖子相关

post_date_format

发表文章的日期显示格式(默认为 '%b %d, %Y'),作为 datetime.date.strftime() 的输入。

post_auto_excerpt

将作为文章摘要显示的段落数(默认为 1)。设置为 0 将导致在存档页中不显示文章摘录。这个选项可以在每个帖子的基础上使用 post 指令选项 excerpt 来设置。

更详细的讨论见 帖子节选和图片

post_auto_image

将显示在文章摘录中的图片的索引。默认是 0,意味着没有图片。设置为 1 将包括第一张图片(如果有的话)到摘录中。这个选项可以在每个帖子的基础上使用 post 指令选项 image 来设置。

post_redirect_refresh

重定向页面在刷新页面之前等待的秒数(默认为 5),以重定向到帖子。

post_always_section

True 时,帖子的标题和摘要总是从包含 post 指令的部分提取,而不是从文档中提取。这是当 post 在一个文档中被多次使用时的行为。默认是 False

博客反馈

通过设置 blog_baseurl 配置变量打开 feeds。

blog_feed_archives

选择按作者、地点、标签、类别和年份创建 feeds,默认为 False

blog_feed_fulltext

选择在博客 feeds 中显示全文,默认为 False

blog_feed_subtitle

博客 feed 的副标题,默认为 None

blog_feed_titles

选择只提供文章标题,默认为 False

blog_feed_templates

一个 feed 文件名根的字典,映射到 feed 条目元素的嵌套字典,title, summary 和/或 content,以及一个 Jinja2 模板,将用于渲染该 feed 中该元素的值。模板的渲染内容如下: feed_length - feed_fulltext - feed_posts - pagename - feed_title - feed_url - feed - post - post_url - content - feed_entry - title - summary - blog - url - app 默认是: {"atom": {}} 例子是 添加一个额外的 feed,用于发布到社交媒体上

blog_feed_templates = {
      # Use defaults, no templates
      "atom": {},
      # Create content text suitable posting to social media
      "social": {
         # Format tags as hashtags and append to the content
         "content": "{{ title }}{% for tag in post.tags %}"
         " #{{ tag.name|trim()|replace(' ', '') }}"
         "{% endfor %}",
      },
}
blog_feed_length

指定在 feeds 中包含的最近帖子的数量,默认为所有帖子的 None

Updated on Sun Aug 24 00:00:00 2014

增加了 blog_feed_archives, blog_feed_fulltext, blog_feed_subtitlepost_always_section 选项。

Updated on Thu Nov 27 00:00:00 2014

增加了 blog_feed_titles, blog_feed_length 和:confval:blog_archive_titles 选项。

Updated on Sat Mar 20 00:00:00 2021

增加 blog_feed_templates 选项。

Font Awesome

ABlog模板将使用 Font Awesome 图标,如果设置了以下一项:

Bootstrap CDN 或其他地方托管的 Font Awesome .css 的 URL。默认: None

Updated on Wed Jul 29 00:00:00 2015

fontawesome_link_cdn 是一个 boolean 选项,现在变成了一个 string 来启用所需的 Font Awesome 版本。要获得旧的行为,请使用 'https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css'

fontawesome_included

Sphinx 主题已经链接到 Font Awesome。默认: False

另外,你可以用以下配置选项提供 Font Awesome .css 的路径:

fontawesome_css_file

Font Awesome .css 的路径(默认为 None),将被 ABlog 在 HTML 输出中链接到。

Disqus 集成

当然,人们无法想到一个博客不允许访问者发表评论。你可以通过设置 disqus_shortnameblog_baseurl 变量来启用 Disqus。从 v0.7.2 开始,要求指定 blog_baseurl 的原因是为了确保当你第一次在本地提供新帖子时,Disqus 将正确的 URL 与线程联系起来。

disqus_shortname

Disqus 网站的简称。

disqus_pages

选择 disqus 是非帖子的页面,默认为 False

disqus_drafts

选择将 disqus 的帖子作为草稿(没有发布日期)。默认为 False

Isso 集成

Disqus 的一个替代方案,是 Isso。集成是由 sphinxnotes-isso 和那里的说明提供的。

博客侧边栏

最后,你可以用 Sphinx html_sidebars 配置选项在你的 HTML 输出中包含七个侧边栏。你在左边看到的侧边栏按照同样的顺序列在下面:

html_sidebars = {
   '**': [...,
          'postcard.html', 'recentposts.html',
          'tagcloud.html', 'categories.html',
          'archives.html', ]
}

postcard.html 提供有关当前帖子的信息。recentposts.html 列出最近的五个帖子。其他的则提供一个链接到为每个标签、类别和年份生成的档案页。此外,还有 authors.htmllanguages.htmllocations.html 等侧边栏,链接到作者和位置的档案页。

命令选项

Updated on Tue Apr 7 00:00:00 2015

添加 ABlog 命令 选项。

ablog_website

构建输出文件的目录名称。默认为 _website

ablog_doctrees

构建缓存文件的目录名称。默认为 .doctrees

ablog_builder

HTML 生成器,默认为 dirhtml。建立 HTML 页面,但每个文件只有一个目录。如果从网络服务器提供服务,可以获得更漂亮的 URL(没有 .html)。替代方案是 html,每个文档建立一个 HTML 文件。

github_pages

GitHub 用户名被 ablog deploy 命令使用。参见 部署到 GitHub Pages部署到 GitHub Pages 获取更多信息。

Comments

comments powered by Disqus