Skip to content

saleor/saleor-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Saleor Documentation

What's In This Document

Get Started in 5 Minutes

  1. Make sure you are using Node in version 20+:
node --version
  1. Install project dependencies:
npm install
  1. Run your dev server:
npm start

Production Build

  1. Build project:
npm run build
  1. Testing build local:
npm run serve

Editing Content

Directory Structure

  • /docs Main docs content directory.
  • /docs/api-reference API reference generated from schema.graphql
  • /docusaurus.config.js Docusaurus configuration file.
  • /docusaurus2-graphql-doc-generator GraphQL API Reference plugin code.
  • /sidebars.js Sidebar menu structure.
  • /static Styling and other static files.

Formatting

Code formatting

Code and response examples should be inside code blocks with proper language:

```graphql
query {
  id
  name
}
```
```json
{
  "errorCode": 400
}
```

Lining pages

Use full path to the file to avoid linking to wrong page.

  • โœ… Example of good link: [Attributes](/docs/developer/attributes.mdx)
  • ๐Ÿ›‘ Avoid: [Attributes](/attributes)

Using custom React components

All documentation files use extension:

  • .mdx - Developer documentation
  • .md - Dashboard documentation

If your page uses custom react components, you are required to use .mdx file extension. Import statement is also required:

## <!-- /docs/developer/export/export-overview.mdx file -->

## title: Exporting Products

import Foo from "@site/components/Foo";

...

<Foo />

For charts we are using Mermaid package.

Editing an existing docs page

Edit docs by navigating to docs/ and editing the corresponding document:

docs/doc-to-be-edited.md

---
id: page-needs-edit
title: This Doc Needs To Be Edited
---

Edit me...

For more information about docs, click here

Adding Content

Adding a new docs page to an existing sidebar

  1. Create the doc as a new markdown file in /docs, example docs/newly-created-doc.md:
---
id: newly-created-doc
title: This Doc Needs To Be Edited
---

My new content here..
  1. Refer to that doc's ID in an existing sidebar in sidebars.js:
// Add newly-created-doc to the Getting Started category of docs
{
  "docs": {
    "Getting Started": [
      "quick-start",
      "newly-created-doc" // new doc here
    ],
    ...
  },
  ...
}

For more information about adding new docs, click here

Adding items to your site's top navigation bar

  1. Add links to docs, custom pages or external links by editing the headerLinks field of siteConfig.js:
{
  headerLinks: [
    ...
    /* you can add docs */
    {
      type: "doc",
      docId: "dashboard/before-you-start",
      label: "Dashboard Manual",
      position: "left",
    },
    /* you can add custom pages */
    { page: 'help', label: 'Help' },
    /* you can add external links */
    { href: 'https://github.com/facebook/Docusaurus', label: 'GitHub' },
    ...
  ],
  ...
}

For more information about the navigation bar, click here

Adding custom pages

  1. Docusaurus uses React components to build pages. The components are saved as .js files in ./pages/en:
  2. If you want your page to show up in your navigation header, you will need to update siteConfig.js to add to the headerLinks element:
{
  headerLinks: [
    ...
    { page: 'my-new-custom-page', label: 'My New Custom Page' },
    ...
  ],
  ...
}

For more information about custom pages, click here.

Updating the API Reference

Files in /docs/api-reference folder are generated by @graphql-markdown/docusaurus package. The introduction page is automatically copied from the /template/api-reference.mdx file.

Updating

To update the API reference:

  1. Get schema.graphql locally into the root of the saleor-docs repository by running curl -O https://raw.githubusercontent.com/saleor/saleor/refs/heads/main/saleor/graphql/schema.graphql
  2. Run npm run update-api-reference

The script behind the scenes does several steps:

  1. The api-reference is generated in .tmp folder.
  2. The highlighting script makes additional improvements in the generated docs. It makes the Saleor version and required permissions more visible.
  3. The current references from docs folder are being removed and generated references in .tmp folder are moved to the docs.
  4. The code examples are being injected. The code examples from the examples folder are being put into corresponding files in the references folder.

Creating links

Tip: To enable autocomplete in VSCode open docs folder in the workspace.

  • Use only absolute paths, which is easier to maintain when moving files around or requires global search and replace.
  • Use the .mdx extension.
  • Start paths with /.
  • Don't use /docs as root path.

Don't:

[Attributes](developer/attributes.mdx)

[Attributes](/developer/attributes)

[Attributes](../../attributes)

[Attributes](/docs/developer/attributes)

Do:

[Attributes](/developer/attributes.mdx)

Search

Saleor Docs are using Algolia DocSearch for the website search.

Crawl interval

DocSearch crawls the website once a week on Friday and aggregates all the content in an Algolia index. This content is then queried directly from the front-end using the Algolia API.

Ranking strategy

The website's search results are meticulously ranked to enhance user relevance and experience. A custom ranking function, known as pageRank, is employed for this purpose. The ranking strategy prioritizes various content categories as follows:

  1. metaPageRank: This takes precedence and is determined by a custom meta attribute, providing a top-tier ranking for specific content.

  2. Documentation Pages: General documentation pages are next in line for ranking, excluding those generated based on schema API reference and API storefront.

  3. API Reference Pages: These pages are ranked differently based on the type of operation they represent.

function pageRank(url) {
  if (metaPageRank) {
    return metaPageRank;
  }
  if (!/\/api-reference\//.test(url.pathname)) {
    // not part of API reference
    return "40";
  }
  if (/\/mutations\//.test(url.pathname)) {
    // mutation
    return "30";
  }
  if (/\/queries\//.test(url.pathname)) {
    // query
    return "20";
  }
  return "10";
}

Manual Ranking Control

For even finer control over search result rankings, you can manually influence the ranking of specified pages by adding a custom meta attribute - rank - to the page. The rank meta is configured to have the highest priority in Algolia.

To assign a custom rank to a particular page, use the following code snippet:

<head>
  <meta name="rank" content="50" />
</head>

Deployment

The main branch is automatically released to docs.saleor.io, which is handled by Vercel.

Linting

Run npm run lint to check for any linting errors on staged (modified) files. Note that capitalization rules don't work well with front matter so you can ignore error messages located in the top --- section.

Debugging

In dev mode, Docusaurus serves a debug page with a list of all available routes and config at http://localhost:3000/\_\_docusaurus/debug.

Full Docusaurus Documentation

Full documentation can be found on the website.

Resources for technical writers

Communicating with precision

Avoid redundancy

Recommended VSCode settings

Create settings.json under .vscode folder with:

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "always"
  },
  "eslint.debug": true,
  "eslint.options": {
    "extensions": [".js", ".jsx", ".md", ".mdx", ".ts", ".tsx"]
  },
  "eslint.runtime": "node",
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "markdown",
    "mdx"
  ],
  "editor.formatOnSave": true
}

Recommended VSCode extensions: