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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-14 00:11:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-14 00:11:00 +0300
commitacba9e99b4f8bfeaaed143b72b07170a8506f893 (patch)
tree3f79c9c68e59c42c79dec7d4b353a3bbb3e118e0 /app/assets/javascripts/helpers
parent716896e8cac8a516cd36efada8c8c5f383b63f62 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/helpers')
-rw-r--r--app/assets/javascripts/helpers/help_page_helper.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/helpers/help_page_helper.js b/app/assets/javascripts/helpers/help_page_helper.js
new file mode 100644
index 00000000000..0e824548646
--- /dev/null
+++ b/app/assets/javascripts/helpers/help_page_helper.js
@@ -0,0 +1,21 @@
+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 {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;
+};