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

20 lines
617 B
JavaScript
Raw Normal View History

2020-10-05 16:49:35 -04:00
import { helper } from '@ember/component/helper';
import { assert } from '@ember/debug';
import config from 'ember-get-config';
2020-10-05 16:49:35 -04:00
2020-11-16 15:08:59 -05:00
export default helper(function docUrl(params /*, hash*/) {
2020-10-05 16:49:35 -04:00
const baseURL = config.documentation.baseURL;
2020-10-05 17:20:04 -04:00
const docKey = params[0] || '';
const configuredPath = config.documentation.topics[docKey];
2020-10-05 16:49:35 -04:00
if (docKey) {
2020-11-16 15:08:59 -05:00
assert(
`
2020-10-05 16:49:35 -04:00
Documentation for "${docKey}" could not be found. Please ensure that
this key exists under "documentation" in your app config.
2020-11-16 15:08:59 -05:00
`,
configuredPath
);
2020-10-05 16:49:35 -04:00
}
const path = configuredPath || '';
return `${baseURL}${path}`;
});