Skip to content

Commit

Permalink
perf: lazy load not found route (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlj95 authored Apr 25, 2024
1 parent c457c0e commit 2aaf6d5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
24 changes: 2 additions & 22 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import { Routes } from '@angular/router'
import { ResumePageComponent } from './resume-page/resume-page.component'
import { NotFoundPageComponent } from './not-found-page/not-found-page.component'
import { METADATA } from './metadata'
import { environment } from '../environments'
import { NgxMetaRouteData } from '@davidlj95/ngx-meta/routing'
import { GlobalMetadata } from '@davidlj95/ngx-meta/core'
import { StandardMetadata } from '@davidlj95/ngx-meta/standard'
import { TwitterCardMetadata } from '@davidlj95/ngx-meta/twitter-card'
import { routes as notFoundPageRoutes } from './not-found-page/routes'

const RESUME_PATH = 'resume'
const NOT_FOUND_PAGE_DATA: NgxMetaRouteData<
GlobalMetadata & StandardMetadata & TwitterCardMetadata
> = {
meta: {
title: `${METADATA.siteName} | Not Found`,
description: 'Page could not be found',
standard: {
author: null,
},
twitterCard: {
creator: { username: null },
site: { username: null },
},
},
}

export const routes: Routes = [
// Metadata to add when '/' route is ready
Expand Down Expand Up @@ -74,6 +55,5 @@ export const routes: Routes = [
},
},
},
{ path: '404', component: NotFoundPageComponent, data: NOT_FOUND_PAGE_DATA },
{ path: '**', component: NotFoundPageComponent, data: NOT_FOUND_PAGE_DATA },
...notFoundPageRoutes,
]
30 changes: 30 additions & 0 deletions src/app/not-found-page/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Route, Routes } from '@angular/router'
import { NgxMetaRouteData } from '@davidlj95/ngx-meta/routing'
import { GlobalMetadata } from '@davidlj95/ngx-meta/core'
import { StandardMetadata } from '@davidlj95/ngx-meta/standard'
import { TwitterCardMetadata } from '@davidlj95/ngx-meta/twitter-card'
import { METADATA } from '../metadata'

const NOT_FOUND_ROUTE_TEMPLATE: Route = {
loadComponent: () =>
import('./not-found-page.component').then((m) => m.NotFoundPageComponent),
data: {
meta: {
title: `${METADATA.siteName} | Not Found`,
description: 'Page could not be found',
standard: {
author: null,
},
twitterCard: {
creator: { username: null },
site: { username: null },
},
},
} satisfies NgxMetaRouteData<
GlobalMetadata & StandardMetadata & TwitterCardMetadata
>,
}
export const routes: Routes = [
{ path: '404', ...NOT_FOUND_ROUTE_TEMPLATE },
{ path: '**', ...NOT_FOUND_ROUTE_TEMPLATE },
]

0 comments on commit 2aaf6d5

Please sign in to comment.