How to use the ember-cli-addon-docs/addon-files.find function in ember-cli-addon-docs

To help you get started, we’ve selected a few ember-cli-addon-docs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ember-learn / ember-cli-addon-docs / addon / components / docs-viewer / x-main / component.js View on Github external
_locateFile(path) {
    path = path.replace(/\./g, '/');
    if (path === 'docs/api/item') {
      let { projectName } = config['ember-cli-addon-docs'];
      let model = getOwner(this).lookup('route:application').modelFor('docs.api.item');
      let filename = model.get('file').replace(new RegExp(`^${projectName}/`), '');
      let file = addonFiles.find(f => f.match(filename));
      if (file) {
        return { file, inTree: 'addon' };
      }
    } else {
      let file = appFiles
        .filter(file => file.match(/\.(hbs|md)$/))
        .find(file => file.match(path));
      if (file) {
        return { file, inTree: 'app' };
      }
    }
  }