Files
threshold-ui/addons/core/addon/helpers/doc-url.js
T

28 lines
805 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2021-11-05 13:20:45 -04:00
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/application';
2020-10-05 16:49:35 -04:00
import { assert } from '@ember/debug';
2021-11-05 13:20:45 -04:00
export default class extends Helper {
compute(params) {
const config = getOwner(this).resolveRegistration('config:environment');
const baseURL = config.documentation.baseURL;
const docKey = params[0] || '';
const configuredPath = config.documentation.topics[docKey];
if (docKey) {
assert(
`
Documentation for "${docKey}" could not be found. Please ensure that
this key exists under "documentation" in your app config.
`,
configuredPath
);
}
const path = configuredPath || '';
return `${baseURL}${path}`;
2020-10-05 16:49:35 -04:00
}
2021-11-05 13:20:45 -04:00
}