FST Network's LOC Documentation, built with React-based Docusaurus 3.x.
Prerequisites: Node.js (latest LTS version), Git and VS Code
Upgrade npm
and install yarn
:
npm i -g npm@latest yarn@latest
Download the repository, install dependencies and open the folder in VS code (VS Code may prompt for installing a few extensions):
git clone https://github.com/fstnetwork/loc-documentation.git
cd loc-documentation
code .
Prerequisites: Github
On the Github repository, click <> Code -> Codespaces -> Create codespace on main. This will start a web version of VS Code with the repository loaded.
Open a terminal in VS Code and run
yarn
If you open the project in CodeSpace, it will automatically run this command as part of the setup.
Build and run a development server, which will hot-reload any changes you've made to most of the files. Be warned that the development server may not throw some build errors.
yarn start
# run dev server at http://localhost:3000
Build a production and serve it locally. The production (under ./build
) can be served by any static web server.
Be noted that the build process may fail due to broken links/anchors in the docs or incompatible upgraded packages. (Warnings can be ignored. You can override these behaviors in docusaurus.config.ts
.)
yarn build
yarn serve
# serve production at http://localhost:3000
Prerequisite: Docker
# build docker image
docker build . -f ./dev-support/containers/local/Dockerfile -t loc-documentation
# run docker container at http://localhost:8080
docker run -d -p 8080:8080 --rm loc-documentation
To commit any changes to the repository:
yarn commit
This action will run format for all docs, sync to the Github repo then push local changes to the repository.
it is recommended to run a build test first if you've made major changes in docs or have upgraded packages.
This repository has a Dependabot configuration that will create pull-requests for upgradable versions of packages.
Upgrade locally and commit:
yarn upgrade {package}@{version}
# or
yarn upgrade {package}@latest # upgrade to latest
# then
yarn commit
Or simply merge pull-requests on Github then update the local version:
git pull origin main && yarn
All docs are written in .mdx
format, which supports both Markdown and React/HTML syntax.
Refer to:
Most of the docs config can be found in docusaurus.config.ts
.
Refer to:
If there are major changes in the index page or navbar items, a new thumbnail photo (/static/img/thumbnail.jpg
) should be created.
The repo will prompt installing a spelling checker in your VS Code environment, which will generate warnings for unrecognized spellings while viewing .md
or .mdx
files.
Due to the requirement of multiple versioning in LOC, LOC-Doc current serve the following docs:
Docs Folder | Root Routing Path | Docs ID | Docs | Versioning |
---|---|---|---|---|
/src/pages |
/ |
General pages without sidebars | No | |
/docs |
/docs |
default |
General docs have sidebars | No |
/docs-main |
/main |
main |
LOC (Core, Studio, CLI) main docs | Yes |
/docs-sdk-ts |
/sdk-ts |
sdk-ts |
SDK for JS/TS docs | Yes |
/docs-sdk-csharp |
/sdk-csharp |
sdk-csharp |
SDK for C# docs | Yes |
/docs-legacy |
/legacy/intro |
legacy |
Legacy docs | Yes (will not add new versions) |
Versioned docs will have the root path of /{path}/{version}/...
.
Links between docs should always pointing to the current (latest) docs. If versioned docs contain links no longer pointing to valid path and/or anchor (which throws error during build), remove the older link.
/docs-draft
are for unused old materials, which will be excluded from the site building process.
Create a .md
or .mdx
file under /src/pages
and it will be accessible via /{page-name}
.
To create a new docs whether or noe it will be versioned:
-
Create a new root folder
docs-{new-docs-id}
. The new ID must be unique from other docs. -
Copy
/sidebars/sidebars.ts
and create a new file named/sidebars/sidebars-{new-docs-id}.ts
-
Add a docs plugin in
docusaurus.config.ts
:
[
"@docusaurus/plugin-content-docs",
{
id: "{new-docs-id}",
path: "docs-{new-docs-id}",
routeBasePath: "{new-docs-id}",
sidebarPath: "./sidebars/sidebars-{new-docs-id}.ts",
showLastUpdateAuthor: true,
showLastUpdateTime: true,
includeCurrentVersion: true,
lastVersion: "current",
onlyIncludeVersions: ["current"],
versions: {
current: {
label: "{docs name}",
path: "",
},
},
},
],
The routeBasePath
is the final routing path on the website, and the pages can be linked via /{new-docs-id}/{page-name}
.
-
Add the docs link
/{new-docs-id}
inthemeConfig.navbar
andthemeConfig.footer
as well as/docs/index.mdx
. -
Update
docsRouteBasePath
anddocsDir
paths in the search plugin@easyops-cn/docusaurus-search-local
to index the new docs. -
Complete the docs.
Versioned docs are older docs preserved for version progressing purposes.
For major or significant minor updates, a new versioned docs should be created:
- Create a versioned docs from the current docs and marked as the previous version:
yarn docusaurus docs:version:{id} {previous-version-number}
Versioned docs will have the path /{id}_versioned_docs/version-{previous-version-number}/
.
-
Edit
docusaurus.config.ts
to include the new previous version underonlyIncludeVersions
andversions
in the corresponding docs plugin. -
Modify the current docs (including the release notes, the displayed sidebar version, etc.) according to the latest release.
-
The latest (current) docs also should update its release notes to include the link of all versioned docs.
-
For the main docs (
/docs-main
), updateonlyIncludeVersions
andversions
in the docs plugin to include versioned docs (which will update the drop down menu). Usedocs-legacy
as the reference. For SDK docs, only the latest versions need to be included (there is no room for extra drop down menus).
In case of a new SDK docs is required, use one of the SDK docs as template and create all the necessary docs/configurations.