This is a static blog website built by docusaurus and hosted by Cloudflare Pages.
The content below will introduce how we implement this website.
Scaffold a skeleton Docusaurus website
npx create-docusaurus@latest my-website classic --typescript
Then npm will install dependencies automatically.
Use yarn instead of npm
cd
my-websiteRemove
my-website/package-lock.jsonRun
yarn
Customize docusaurus.config.js
Remove all about
/docsand clean all files under/blogUpdate all default fields
Add i18n
- Add locale switcher in
navbarconfig
{
"type": "localeDropdown",
"position": "right"
}
Use
write-translationsCLI, now we add localezh-Hansby runningyarn write-translations --locale zh-HansUpdate
jsonand.mdgenerated by step 2
Connect to Cloudflare Pages
Sign in Cloudflare Pages.
Connect to Github account and select target repo.
Here's an example of Build configurations:
Build command: yarn && yarn build
Build output directory: /build
Root directory: /my-website
Build comments on pull requests: Enabled
Here's an example of environment-variables:
| Variable name | Value |
|---|---|
| NODE_VERSION | 16.13.1 |
| YARN_VERSION | 1.22.17 |
Any new commits pushed to main branch will trigger build.
