Node.js 12+ is installed in the system.
If you don't have Node.js installed, ir it's version is smaller than 12, then follow this guide to install it.
yarn
is installed in the system as a package manager.
Yarn in an alternative package manager for Node.js. It needs to be installed separately. If you already have Node.js installed run the following command to add Yarn:
npm install --global yarn
Clone the repo and init submodules with the actual docs:
git clone [email protected]:gravitational/next.git
git submodule init
To update docs to the latest version form master run:
yarn git-update
Install dependencies with:
yarn
Now run one of the following commands:
yarn dev
- will run development server atlocalhost:3000
that will autorefresh pages in real time then you edit markdown documents.yarn build
- will build static production version.yarn start
- will display documentation built withnpm run build
atlocalhost:3000
.yarn update-and-build
- shortcut for submodule update and build (this command is used on deploy to vercel). Do not use this command if you plan to edit docs locally - on run it will switch you branch to latest commit inmaster
that can cause conflicts with your locally edited files.
yarn test
– run tests. Used on CI.yarn lint
– checks JS and TS files for errors and automatically fixes them.yarn lint-check
– checks JS and TS files for errors, but didn't fix them. Checked in CI and on commit.yarn typecheck
– validate TypeScript type-related errors. Used on CI.yarn git-update
– shortcut for submodule update, laso used as part ofyarn update-and-build
.yarn build-loaders
– command used to build custom webpack loaders.yarn add-symlinks
– this command creates symlinks from different versions of docs topages
directory.yarn markdown-lint
– lint*.mdx
files insidecontent/**/docs/pages/
folders for syntax errors.yarn markdown-lint-external-links
– same asyarn markdown-lint
but checks that external links works. Separate command because of slowness.
File that configures build options:
versions
- array of the available options, should match the names of the folders inside content
dir. Will be shouwn in the version select in the inverted order.
Format of version entry:
name
- required. Name of the folder incontent
and name of branch in versions dropdown on the site.branch
- required. Name of branch for this version. Will be used foredit
links on the docs pages.latest
- not required. First entry with this field will be current version. If no entries has this field, then the last version in array will be considered the latest.
content/*.*/docs
- is a docs folder. Inside of it we have docs for diffrent teleport version with the following structure:
img/
- folder for images used inside the pages.pages/
-.md
or.mdx
files with actual page content. Every file in this folder will be rendered as a page.config.json
- docs version config.
- Add new submodule:
git submodule add -b branch/*.* https://github.com/gravitational/teleport/ content/*.*
wherebranch/*.*
is the name of the branch in the main Teleport repo andcontent/*.*
is the name of the subfolder in thecontent
folder there the docs will be stored. Name of the folder insidecontent
should match the name of the version in the config. Folder name itself can contain any characters allowed in the URL. E.g.6.0-rc
. - Add new entry to the
versions
array inconfig.json
with name and branch field. - Change
latest
field to the new value if you want to make it default.
- Open
.gitmodules
file. - Find corresponding record. For example, for version
4.4
it will look like this:[submodule "content/4.4"] path = content/4.4 url = https://github.com/gravitational/teleport/ branch = branch/4.4
- Change
branch
field to the new branch name. - Run
yarn git-update
– this will update all submodules to the HEAD commits of the corresponding branches.
Correct way to remove submodule:
# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule
# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule
# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule