Docusaurus2 可疾速搭建文档、博客、官网等网站,并公布到 GitHub Pages, Serverless 等。

咱们只需 Markdown 写写内容就行,也可间接编写 React 组件嵌入。而 SEO、搜寻、版本等都敌对反对了。

另外重要的一点是此我的项目是 Facebook 开源保护的,他们本人也在用,所以品质、短暂性能有所保障。

  • 代码: https://github.com/ikuokuo/st...
  • 演示: https://ikuokuo.github.io/sta... ????

前提筹备

  • Node.js version >= 10.15.1
  • Yarn version >= 1.5
❯ node -vv12.18.4❯ yarn versionyarn version v1.22.10

创立我的项目

# npx @docusaurus/init@latest init [name] [template]npx @docusaurus/init@latest init my-website classic

运行输入:

Success! Created my-websiteInside that directory, you can run several commands:  yarn start    Starts the development server.  yarn build    Bundles the app into static files for production.  yarn deploy    Publish website to GitHub pages.We suggest that you begin by typing:  cd my-website  yarn startHappy hacking!

运行利用

cd my-website/yarn start

拜访 http://localhost:3000/start-docusaurus2/ 本地地址。

公布到 [GitHub Pages][]

批改 docusaurus.config.js

module.exports = {  title: 'My Site',  tagline: 'The tagline of my site',  url: 'https://ikuokuo.github.io',  baseUrl: '/start-docusaurus2/',  onBrokenLinks: 'throw',  favicon: 'img/favicon.ico',  organizationName: 'ikuokuo',  projectName: 'start-docusaurus2',  ...};

公布:

cd my-website/GIT_USER=ikuokuo USE_SSH=true yarn deploy

拜访 https://ikuokuo.github.io/sta... 在线地址。

公布到 Serverless

  • 阿里云 函数计算
  • 腾讯云 Serverless
GoCoding 集体实际的教训分享,可关注公众号!