Adding a Blog
初始设置
要设置你的网站博客,需在你的工程website
目录下先创建一个blog
目录。
然后, 在 siteConfig.js
中添加一个指向您博客的 headerLinks
:
headerLinks: [
...
{blog: true, label: 'Blog'},
...
]
添加文章
To publish in the blog, create a file within the blog folder with a formatted name of YYYY-MM-DD-My-Blog-Post-Title.md
. The post date is extracted from the file name.
例如, 文件 website/blog/2017-08-18-Introducing-Docusaurus.md
:
---
author: Frank Li
authorURL: https://twitter.com/foobarbaz
authorFBID: 503283835
title: Introducing Docusaurus
---
Lorem Ipsum...
顶部选项
唯一必填项是 title
;但是, 我们还提供了添加可选的文章作者信息的功能。
author
- 作者署名的文本标签。authorURL
- The URL associated with the author. This could be a Twitter, GitHub, Facebook account, etc.authorFBID
- The Facebook profile ID that is used to fetch the profile picture.authorImageURL
- The URL to the author's image. (Note: If you use bothauthorFBID
andauthorImageURL
,authorFBID
will take precedence. Don't includeauthorFBID
if you wantauthorImageURL
to appear.)title
- The blog post title.
摘要截取
在播客文章中使用 <!--truncate-->
标记,这样,在浏览全部已发布的文章时,就可以看到博客中各文章的摘要信息。 <!--truncate-->
标记以上的内容都会成为摘要。 例如:
---
title: Truncation Example
---
All this will be part of the blog post summary.
Even this.
<!--truncate-->
But anything from here on down will not be.
Not this.
Or this.
修改侧边栏可见的文章数
默认情况下,侧边栏会显示最近的5篇文章。
你可以在 siteConfig.js
中添加 blogSidebarCount
属性,来配置你的想要展示的文章数。
可用的选项是一个整数或字符串'ALL',表示您希望显示的文章数量。
例如:
blogSidebarCount: 'ALL'
RSS订阅
Docusaurus provides a simple RSS feed for your blog posts. Both RSS and Atom feed formats are supported. This data is automatically to your website page's HTML
标签
A summary of the post's text is provided in the RSS feed up to the <!--truncate-->
. If no <!--truncate-->
tag is found, then all text up 250 characters are used.
社交按钮
如果想在文章底部显示Facebook与(或)Twitter社交按钮,那么在网站设置的siteConfig.js
中配置facebookAppId
与(或) twitter
选项。