Node.js 12+ is installed in the system.
If you don't have Node.js installed, or 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 git@github.com:gravitational/next.git
git submodule init
To update docs to the latest version from master run:
yarn git-update
Install dependencies with:
yarn
Now run one of the following commands:
yarn dev
- will run development server for docs atlocalhost:3000/docs
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.yarn markdown-fix
– automatically fix syntax in*.mdx
files insidecontent/**/docs/pages/
.yarn storybook
– run Storybook instance at the6006
port. You can check existing components here and try different options.yarn build-storybook
– build static version of Storybook.
File that configures build options:
versions
- array of the available options, should match the names of the folders insidecontent
dir. Will be shown in the version select in the inverted order.redirects
- optional array of redirects. Uses Next.js syntax inside.
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 different 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
(= variable =)
– will insert variable fromdocs/config.json
'svaraibles
field.(! path-to-file.yaml !)
- will insert files content in the docs. Path should be relative to submodule's root.
Suffix @Nx
at the end of the image name will tell browser to scale image down by the number after the @
.
E. g. filename@2x.png
mans that this image is retina-ready and should be rendered at half size. Same with @3x
, @1.5x
, etc.