Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending the built-in routes... #125

Open
mswanson opened this issue Jun 8, 2021 · 0 comments
Open

Extending the built-in routes... #125

mswanson opened this issue Jun 8, 2021 · 0 comments

Comments

@mswanson
Copy link

mswanson commented Jun 8, 2021

I am trying to add some additional functionality to the built-in routes and I am wondering if there is a preferred method for doing this. My first thought was to extend the routes by creating a local route named the same thing in my theme (e.g routes/index.js).

import Route from '@ember/routing/route';

export default class Index extends Route {
  // custom stuff here..
}

This does what I would expect, it replaces the add-on route. What I want, however, is to extend the addon route. I have tried several permutations of an import statement to import and extend the add-on route but nothing seems to work.

// import Route from '@ember/routing/route';
import { default as IndexRoute } from 'empress-blog/addon/routes/index';

export default class Index extends IndexRoute {
  constructor() {
    super(...arguments);
  }

  // custom stuff here...
}

I get an import error Error: Could not find module 'empress-blog/addon/routes/index' imported from 'my-app-theme/routes/index'. I am not sure if it's because the add-on adds the route into the consuming app's app folder or if I need to do some broccoli magic. Anyway, any thoughts you have would be appreciated. For now, the work around I am doing is to copy the contents of the route in the addon into my local route and just replace the one coming from the addon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant