docusaurus는 문서에 대한 버전 관리가 가능하다.
버전 추가 방법은 튜토리얼 페이지에도 나와있으나, 잊지 않도록 기록해둔다.
docusaurus 프로젝트 위치에서 npm run docusaurus docs:version {버전명} 을 실행한다.
❯ npm run docusaurus docs:version 0.0.1
> tempsaurus@0.0.0 docusaurus
> docusaurus docs:version 0.0.1
[INFO] Versioned docs will be created for the following locales:
- en
- ko
[WARNING] [docs]: no docs found in "/mnt/c/Users/user/Desktop/tempsaurus/i18n/en/docusaurus-plugin-content-docs/current". Skipping.
[SUCCESS] [docs]: version 0.0.1 created!
실행 이후 아래 내용이 자동으로 추가된다.
tempsaurus/
┣ # ...
┣ versioned_docs/ # new
┃ ┗ version-0.0.1/ # 커맨드에 추가한 버전명
┣ versioned_sidebars/ # new
┃ ┗ version-0.0.1-sidebars.json # 사이드바도 버전에 따라 추가된다.
┣ # ...
┗ versions.json # 버전 리스트를 저장하는 파일
자동으로 추가된 versions.json 내용은 아래와 같다.
[
"0.0.1"
]
docusaurus.config.js 에 해당 파트에 추가한다. 상세 위치 어디인지는 생략.
module.exports = {
themeConfig: {
navbar: {
items: [
// ... 🙄
{ type: 'docsVersionDropdown', position: 'right' },
// ... 🙄
],
},
},
};
로컬 서버 재시작 후, 확인하면 총 2 버전이 보인다.
/docs에 있는 내용들docusaurus docs:version 으로 만들어진 버전의 내용들dropDown 구성은 공식 문서에 상세가 잘 나와있다.
docSidebar로 구성하는게 제일 편해보인다.