Skip to content

Commit

Permalink
fix: improve matcher routing for SEO URLs (#1387, #1409)
Browse files Browse the repository at this point in the history
* reordered check for routing matches to first check product routes then category routes and at the end content page routes (to be less eager to assume it is a content page)
* replace all occurences of object markers (pg, prd, ctg) in slug data instead of only the first (to prevent unintended object markers with multiple occurences)
* updated ts configuration to use the Angular 15 standard configuration of `ES2022` for `lib` that includes `replaceAll`
- `replaceAll('pg', 'Pg')` could be replaced by `replace(/pg/g, 'Pg')`
  • Loading branch information
shauke committed Apr 4, 2023
1 parent 0fd2766 commit f952dc9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docs/guides/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ The Intershop PWA now uses Node.js 18.15.0 LTS with the corresponding npm versio
To migrate to this version, it is advised to delete the locale `package-lock.json` beforehand.

The project was updated to work with Angular 15.
This includes the removal of the Browserslist configuration, an updated TypeScript compiler `target` to `ES2022`, and adaptions of the Schematics configurations and tests.
This includes the removal of the Browserslist configuration and an updated TypeScript compiler `target` and `lib` to `ES2022` (for browser support requirements that differ from the Angular 15 standard configuration see the [configuring browser compatibility](https://angular.io/guide/build#configuring-browser-compatibility) guide and the [TypeScript configuration](https://angular.io/guide/typescript-configuration) reference).
Adaptions of the Schematics configurations and tests were necessary as well.
In addition, all other dependencies were updated as well and resulted in necessary Stylelint and Jest test adaptions.

The placeholder for theme-specific assets and styles has been changed from `placeholder` to `theme_placeholder`.
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/utils/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function sanitizeSlugData(slugData: string) {
.replace(/-+/g, '-')
.replace(/-+$/, '')
.toLowerCase()
.replace('pg', 'Pg')
.replace('prd', 'Prd')
.replace('ctg', 'Ctg') || ''
.replaceAll('pg', 'Pg')
.replaceAll('prd', 'Prd')
.replaceAll('ctg', 'Ctg') || ''
);
}
8 changes: 4 additions & 4 deletions src/app/pages/app-last-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { matchContentRoute } from 'ish-core/routing/content-page/content-page.ro
import { matchProductRoute } from 'ish-core/routing/product/product.route';

const routes: Routes = [
{
matcher: matchContentRoute,
loadChildren: () => import('./content/content-page.module').then(m => m.ContentPageModule),
},
{
matcher: matchProductRoute,
loadChildren: () => import('./product/product-page.module').then(m => m.ProductPageModule),
Expand All @@ -19,6 +15,10 @@ const routes: Routes = [
matcher: matchCategoryRoute,
loadChildren: () => import('./category/category-page.module').then(m => m.CategoryPageModule),
},
{
matcher: matchContentRoute,
loadChildren: () => import('./content/content-page.module').then(m => m.ContentPageModule),
},
{
path: '**',
canActivate: [notFoundStatusGuard],
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"downlevelIteration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
// leave this as CommonJS, so scripts can be run with 'npx ts-node'
// see https://github.com/TypeStrong/ts-node#commonjs-vs-native-ecmascript-modules
"module": "CommonJS",
"moduleResolution": "node",
"importHelpers": true,
Expand All @@ -25,7 +27,7 @@
],
"swiper_angular": ["node_modules/swiper/angular"]
},
"lib": ["es2018", "dom"],
"lib": ["ES2022", "dom"],
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": true,
Expand Down

0 comments on commit f952dc9

Please sign in to comment.