diff --git a/packages/docusaurus-init/templates/bootstrap/blog/2019-05-28-hola.md b/packages/docusaurus-init/templates/bootstrap/blog/2019-05-28-hola.md new file mode 100644 index 0000000000..5552da124f --- /dev/null +++ b/packages/docusaurus-init/templates/bootstrap/blog/2019-05-28-hola.md @@ -0,0 +1,11 @@ +--- +id: hola +title: Hola +author: Gao Wei +author_title: Docusaurus Core Team +author_url: https://github.com/wgao19 +author_image_url: https://avatars1.githubusercontent.com/u/2055384?v=4 +tags: [hola, docusaurus] +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet diff --git a/packages/docusaurus-init/templates/bootstrap/blog/2019-05-29-hello-world.md b/packages/docusaurus-init/templates/bootstrap/blog/2019-05-29-hello-world.md new file mode 100644 index 0000000000..3b33193938 --- /dev/null +++ b/packages/docusaurus-init/templates/bootstrap/blog/2019-05-29-hello-world.md @@ -0,0 +1,17 @@ +--- +id: hello-world +title: Hello +author: Endilie Yacop Sucipto +author_title: Maintainer of Docusaurus +author_url: https://github.com/endiliey +author_image_url: https://avatars1.githubusercontent.com/u/17883920?s=460&v=4 +tags: [hello, docusaurus] +--- + +Welcome to this blog. This blog is created with [**Docusaurus 2 alpha**](https://v2.docusaurus.io/). + + + +This is a test post. + +A whole bunch of other information. diff --git a/packages/docusaurus-init/templates/bootstrap/blog/2019-05-30-welcome.md b/packages/docusaurus-init/templates/bootstrap/blog/2019-05-30-welcome.md new file mode 100644 index 0000000000..3b5affedce --- /dev/null +++ b/packages/docusaurus-init/templates/bootstrap/blog/2019-05-30-welcome.md @@ -0,0 +1,13 @@ +--- +id: welcome +title: Welcome +author: Yangshun Tay +author_title: Front End Engineer @ Facebook +author_url: https://github.com/yangshun +author_image_url: https://avatars0.githubusercontent.com/u/1315101?s=400&v=4 +tags: [facebook, hello, docusaurus] +--- + +Blog features are powered by the blog plugin. Simply add files to the `blog` directory. It supports tags as well! + +Delete the whole directory if you don't want the blog features. As simple as that! diff --git a/packages/docusaurus-init/templates/bootstrap/docusaurus.config.js b/packages/docusaurus-init/templates/bootstrap/docusaurus.config.js index 51fe23e61b..f8f9b4d7ab 100644 --- a/packages/docusaurus-init/templates/bootstrap/docusaurus.config.js +++ b/packages/docusaurus-init/templates/bootstrap/docusaurus.config.js @@ -54,5 +54,5 @@ module.exports = { copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`, }, }, - presets: [['@docusaurus/preset-bootstrap', {}]], + presets: [['@docusaurus/preset-bootstrap']], }; diff --git a/packages/docusaurus-preset-bootstrap/package.json b/packages/docusaurus-preset-bootstrap/package.json index b3b2c0b40d..7dfd7ccfa0 100644 --- a/packages/docusaurus-preset-bootstrap/package.json +++ b/packages/docusaurus-preset-bootstrap/package.json @@ -8,6 +8,8 @@ "access": "public" }, "dependencies": { + "@docusaurus/theme-bootstrap": "^2.0.0-alpha.50", + "@docusaurus/plugin-content-blog": "^2.0.0-alpha.50", "@docusaurus/plugin-content-pages": "^2.0.0-alpha.50" }, "peerDependencies": { diff --git a/packages/docusaurus-preset-bootstrap/src/index.js b/packages/docusaurus-preset-bootstrap/src/index.js index f0d18bed29..f5a34dfc72 100644 --- a/packages/docusaurus-preset-bootstrap/src/index.js +++ b/packages/docusaurus-preset-bootstrap/src/index.js @@ -8,6 +8,9 @@ module.exports = function preset(context, opts = {}) { return { themes: [['@docusaurus/theme-bootstrap', opts.theme]], - plugins: [['@docusaurus/plugin-content-pages', opts.pages]], + plugins: [ + ['@docusaurus/plugin-content-pages', opts.pages], + ['@docusaurus/plugin-content-blog', opts.blog], + ], }; }; diff --git a/packages/docusaurus-theme-bootstrap/src/theme/BlogListPage/index.js b/packages/docusaurus-theme-bootstrap/src/theme/BlogListPage/index.js new file mode 100644 index 0000000000..5f194f4867 --- /dev/null +++ b/packages/docusaurus-theme-bootstrap/src/theme/BlogListPage/index.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; +import BlogPostCard from '@theme/BlogPostItem'; + +function BlogListPage(props) { + const {items} = props; + + return ( +
+
+ {items.map(({content: BlogPostContent}) => ( +
+ +
+ ))} +
+
+ ); +} + +export default BlogListPage; diff --git a/packages/docusaurus-theme-bootstrap/src/theme/BlogPostItem/index.js b/packages/docusaurus-theme-bootstrap/src/theme/BlogPostItem/index.js new file mode 100644 index 0000000000..a0eb3bda8b --- /dev/null +++ b/packages/docusaurus-theme-bootstrap/src/theme/BlogPostItem/index.js @@ -0,0 +1,85 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; + +const MONTHS = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', +]; + +function BlogPostItem(props) { + const {frontMatter, metadata, truncated} = props; + + const {date, readingTime} = metadata; + const {author, title} = frontMatter; + + const authorURL = frontMatter.author_url || frontMatter.authorURL; + const authorImageURL = + frontMatter.author_image_url || frontMatter.authorImageURL; + + const match = date.substring(0, 10).split('-'); + const year = match[0]; + const month = MONTHS[parseInt(match[1], 10) - 1]; + const day = parseInt(match[2], 10); + + return ( +
+
+
+ {authorImageURL && ( + {author} + )} +
+
+ {author && ( +
+ + {author} + +
+ )} + +
+
+ +
+

{title}

+

Markdown content

+
+ +
+ {readingTime && ( + + {Math.ceil(readingTime)} min read + + )} + {truncated && ( + + Read more + + )} +
+
+ ); +} + +export default BlogPostItem; diff --git a/packages/docusaurus-theme-bootstrap/src/theme/BlogPostPage/index.js b/packages/docusaurus-theme-bootstrap/src/theme/BlogPostPage/index.js new file mode 100644 index 0000000000..6950c8f165 --- /dev/null +++ b/packages/docusaurus-theme-bootstrap/src/theme/BlogPostPage/index.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export default () => {}; diff --git a/packages/docusaurus-theme-bootstrap/src/theme/BlogTagsListPage/index.js b/packages/docusaurus-theme-bootstrap/src/theme/BlogTagsListPage/index.js new file mode 100644 index 0000000000..6950c8f165 --- /dev/null +++ b/packages/docusaurus-theme-bootstrap/src/theme/BlogTagsListPage/index.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export default () => {}; diff --git a/packages/docusaurus-theme-bootstrap/src/theme/BlogTagsPostsPage/index.js b/packages/docusaurus-theme-bootstrap/src/theme/BlogTagsPostsPage/index.js new file mode 100644 index 0000000000..6950c8f165 --- /dev/null +++ b/packages/docusaurus-theme-bootstrap/src/theme/BlogTagsPostsPage/index.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export default () => {};