This website is built using Docusaurus 2, a modern static website generator.
npx create-docusaurus@latest my-website classic
cd my-website
npm run start
npm run build
Contents will be generated within the
/build
directory, which can be copied to any static file hosting service like GitHub pages, Vercel or Netlify.
my-website
βββ blog
β βββ 2019-05-28-hola.md
β βββ 2019-05-29-hello-world.md
β βββ 2020-05-30-welcome.md
βββ docs
β βββ doc1.md
β βββ doc2.md
β βββ doc3.md
β βββ mdx.md
βββ src
β βββ css
β β βββ custom.css
β βββ pages
β βββ styles.module.css
β βββ index.js
βββ static
β βββ img
βββ docusaurus.config.js
βββ package.json
βββ README.md
βββ sidebars.js
βββ yarn.lock
All important configuration are setted into docusaurus.config.js
The high-level overview of Docusaurus configuration can be categorized into:
- Site metadata
- Deployment configurations
- Theme, plugin, and preset configurations
- Custom configurations
Your configuration object will be made available to all the components of your site. And you may access them via React context as siteConfig
.
import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
const Hello = () => {
const {siteConfig} = useDocusaurusContext();
const {title, tagline} = siteConfig;
return <div>{`${title} Β· ${tagline}`}</div>;
};
Visit Docusaurus guides documentation
- Pages
- Docs
- Blog
- Markdown features
- Styling and layout
- Swizzling
- Static assets
- Search
- Browser support
- SEO
- Using Plugins
- Deployment
- Internationalization
- Add an option into the navbar from
docusaurus.config.js
:
navbar: {
title: 'My Site',
items: [
...
{to: '/blog', label: 'Blog', position: 'left'},
{
to: '/notes',
label: 'My Notes',
position: 'left'
},
{
}
-
Create
Notes.jsx
component intosrc/pages/
. -
create
content.config.js
into/docs/
:
export const topics = [
{
name: 'Laravel',
img: '',
path: ''
},
{
name: 'React',
img: '',
path: ''
},
];
npm install --save @easyops-cn/docusaurus-search-local
Add this plugin to the plugins array in docusaurus.config.js.
plugins: [
[
require.resolve("@easyops-cn/docusaurus-search-local"),
({
// ... Your options.
// `hashed` is recommended as long-term-cache of index file is possible.
hashed: true,
// For Docs using Chinese, The `language` is recommended to set to:
// ```
// language: ["en", "zh"],
// ```
}),
],
],
Search does not work in development (i.e., when running
npm run docusaurus start
). If you want to test search locally, first build the documentation withnpm run docusaurus build
, and then serve it vianpm run docusaurus serve
https://github.com/easyops-cn/docusaurus-search-local
npm install docusaurus-plugin-image-zoom --save
Configuration
{
plugins: [require.resolve("docusaurus-plugin-image-zoom")];
}
Options
themeConfig: {
zoom: {
selector: '.markdown :not(em) > img',
config: {
// options you can specify via https://github.com/francoischalifour/medium-zoom#usage
background: {
light: 'rgb(255, 255, 255)',
dark: 'rgb(50, 50, 50)'
}
}
}
},
cmd /C "set GIT_USER=my-user && npm run deploy"
npm run swizzle