Ghost/ghost/admin/app/routes/error404.js
Kevin Ansfield c56bfd51de Fixed posts list hrefs showing "mobiledoc-editor" and added "editor-beta" redirects
no issue

- switched posts list over to using the `lexical-editor.edit` route so it uses the `/editor/` href rather than `/mobiledoc-editor/`
- added redirect handling for the `/editor-beta/*` urls to our generic 404 route so anyone upgrading with the beta URLs still open in tabs or saved won't hit a 404
2023-10-04 14:37:12 +01:00

38 lines
893 B
JavaScript

import Route from '@ember/routing/route';
import {inject as service} from '@ember/service';
export default class Error404Route extends Route {
controllerName = 'error';
templateName = 'error';
@service router;
beforeModel(transition) {
// handle redirects for old routes
if (transition.to?.params?.path?.startsWith?.('editor-beta')) {
const [, type, postId] = transition.to.params.path.split('/');
const route = postId ? 'lexical-editor.edit' : 'lexical-editor.new';
const models = [type];
if (postId) {
models.push(postId);
}
return this.router.transitionTo(route, ...models);
}
}
model() {
return {
status: 404
};
}
buildRouteInfoMetadata() {
return {
titleToken: 'Error'
};
}
}