diff --git a/docs/guides-blog.md b/docs/guides-blog.md index b59519fe7a..25bee7d1c7 100644 --- a/docs/guides-blog.md +++ b/docs/guides-blog.md @@ -68,6 +68,19 @@ Not this. Or this. ``` +## Changing How Many Blog Posts Show on Sidebar + +By default, 5 recent blog posts are shown on the sidebar. + +You can configure a specifc amount of blog posts to show by adding a `blogSidebarCount` setting to your `siteConfig.js`. + +The available options are an integer repreenting the number of posts you wish to show or a string with the value 'ALL'. + +Example: +``` +blogSidebarCount: 'ALL' +``` + ## RSS Feed 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
tag. diff --git a/lib/core/BlogSidebar.js b/lib/core/BlogSidebar.js index e1933fd89b..2c01893367 100644 --- a/lib/core/BlogSidebar.js +++ b/lib/core/BlogSidebar.js @@ -13,16 +13,28 @@ const MetadataBlog = require('./MetadataBlog.js'); class BlogSidebar extends React.Component { render() { + let blogSidebarCount = 5; + let blogSidebarTitle = 'Recent Posts'; + if (this.props.config.blogSidebarCount) { + if (this.props.config.blogSidebarCount == 'ALL') { + blogSidebarCount = MetadataBlog.length; + blogSidebarTitle = 'All Blog Posts'; + } else { + blogSidebarCount = this.props.config.blogSidebarCount; + } + } + const contents = [ { - name: 'Recent Posts', - links: MetadataBlog.slice(0, 5), + name: blogSidebarTitle, + links: MetadataBlog.slice(0, blogSidebarCount), }, ]; const title = this.props.current && this.props.current.title; + const current = { id: title || '', - category: 'Recent Posts', + category: blogSidebarTitle, }; return (