Skip to content

Documentation

  • You learned something about crate2nix that isn’t documented or described in a bad way?
  • You noticed some bad grammar?
  • You spotted some overcomplicated wording?
  • You want to spice up the layout?

πŸš€ Awesome. Contribute by improving the documentation! If you are not sure about something, make a rough draft or explain what you want to do, submit a PR and ask for feedback early.

⚑ Editing directly in GitHub

If you want to edit an already existing page, you can click on the β€œEdit page” link at the bottom of the page. It will lead you to in-place editing in GitHub.

This will eventually allow you to create a pull request with your changes. Check for any β€œbuild errors” β€” there is some linting that is run across the markdown files and it is rather strict.

πŸ’» Editing the documentation in a local copy

crate2nix uses Starlight and Astro to provide this GitHub page. All the docs are in the docs folder of the source repo.

  • Enter a dev shell: nix develop or direnv allow if you use direnv.
  • Enter docs directory: cd docs
  • Install dependencies: npm install
  • Preview your docs continuously: npm run dev
  • Edit Loop
    • Edit: Make your changes.
    • Preview: Preview your changes locally.
    • Build in nix: git add your changes.
    • Lint: pre-commit run local lints.
  • CHANGELOG: Add yourself to the changelog to get some well-deserved recognition in the release notes!
  • Build in nix: run nix flake check.
  • Create your pull request

🧞 Using NPM Commands

All commands are run from the docs folder of the project, from a terminal:

CommandAction
nix developEnter a dev shell if you haven’t enabled direnv
npm installInstalls dependencies
npm run devStarts local dev server at localhost:4321
npm run buildBuild your production site to ./dist/
npm run previewPreview your build locally, before deploying
npm run astro ...Run CLI commands like astro add, astro check
npm run astro -- --helpGet help using the Astro CLI

🧞 Linting, checking, building

CommandAction
nix developEnter a dev shell if you haven’t enabled direnv
nix build .#docsBuilding docs with nix
nix flake checkRunning build AND lints
pre-commitRunning pre-commit lints without committing.

πŸš€ Docs Project Structure

Inside of your Astro + Starlight project, you’ll see the following folders and files:

.
β”œβ”€β”€ public/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ assets/
β”‚ β”œβ”€β”€ content/
β”‚ β”‚ β”œβ”€β”€ docs/
β”‚ β”‚ └── config.ts
β”‚ └── env.d.ts
β”œβ”€β”€ astro.config.mjs
β”œβ”€β”€ package.json
└── tsconfig.json

Starlight looks for .md or .mdx files in the src/content/docs/ directory. Each file is exposed as a route based on its file name.

Images can be added to src/assets/ and embedded in Markdown with a relative link.

Static assets, like favicons, can be placed in the public/ directory.

πŸ‘€ Want to learn more about Starlight/Astro?

Check out Starlight’s docs, read the Astro documentation, or jump into the Astro Discord server.

πŸ‘€ Want to learn more about structuring documentation?

And help me with it πŸ˜€