Welcome to mirror list, hosted at ThFree Co, Russian Federation.

help_page_helper.js « helpers « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 21d27b5fea9412ca9a9f6bc5cc70a18c35d4f692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { joinPaths, setUrlFragment } from '~/lib/utils/url_utility';

const HELP_PAGE_URL_ROOT = '/help/';

/**
 * Generate link to a GitLab documentation page.
 *
 * This is designed to mirror the Ruby `help_page_path` helper function, so that
 * the two can be used interchangeably.
 * @param {string} path - Path to doc file relative to the doc/ directory in the GitLab repository.
 *   Optionally, including `.md` or `.html` prefix
 * @param {object} [options]
 *   @param {string} [options.anchor] - Name of the anchor to scroll to on the documentation page.
 */
export const helpPagePath = (path, { anchor = '' } = {}) => {
  let helpPath = joinPaths(gon.relative_url_root || '/', HELP_PAGE_URL_ROOT, path);
  if (anchor) {
    helpPath = setUrlFragment(helpPath, anchor);
  }

  return helpPath;
};