Skip to content

Commit

Permalink
fix: capture entire URL for page viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts committed Mar 11, 2019
1 parent fd04d9a commit 3ea3118
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { PageNotFoundComponent, PageComponent } from './core/components';
{ path: '', redirectTo: '/blog', pathMatch: 'full' },
{ path: 'blog', loadChildren: './blog/blog.module#BlogModule' },
{ path: '404', component: PageNotFoundComponent },
{ path: ':pageId', component: PageComponent },
{ path: '**', component: PageComponent },
]),
MarkdownModule.forRoot(),
CoreModule
Expand Down
9 changes: 5 additions & 4 deletions src/app/core/components/page/page.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { tap, switchMap } from 'rxjs/operators';
import { tap, switchMap, map } from 'rxjs/operators';

import { PageService } from 'src/app/core/services';

Expand All @@ -23,9 +23,10 @@ import { PageService } from 'src/app/core/services';
]
})
export class PageComponent implements OnInit {
page$ = this.route.paramMap.pipe(
switchMap(params =>
this.postService.getPageContent(params.get('pageId'))
page$ = this.route.url.pipe(
map(paths => paths.reduce((curr, path) => curr += `/${path.path}`, '')),
switchMap(pagePath =>
this.postService.getPageContent(pagePath)
.pipe(tap(() => {}, () => {
this.router.navigate(['/404']);
}))
Expand Down

0 comments on commit 3ea3118

Please sign in to comment.