-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add page viewer component and move about to markdown file
- Loading branch information
1 parent
8cfd447
commit abf1c68
Showing
9 changed files
with
94 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './about/about.component'; | ||
export * from './layout/layout.component'; | ||
export * from './page/page.component'; | ||
export * from './page-not-found/page-not-found.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { tap, switchMap } from 'rxjs/operators'; | ||
|
||
import { PageService } from 'src/app/core/services'; | ||
|
||
@Component({ | ||
selector: 'app-page', | ||
template: ` | ||
<markdown [data]="page$ | async"></markdown> | ||
`, | ||
styles: [ | ||
` | ||
:host { | ||
display: flex; | ||
width: 80%; | ||
} | ||
markdown { | ||
width: 100%; | ||
} | ||
` | ||
] | ||
}) | ||
export class PageComponent implements OnInit { | ||
page$ = this.route.paramMap.pipe( | ||
switchMap(params => | ||
this.postService.getPageContent(params.get('pageId')) | ||
.pipe(tap(() => {}, () => { | ||
this.router.navigate(['/404']); | ||
})) | ||
) | ||
); | ||
|
||
constructor( | ||
private router: Router, | ||
private route: ActivatedRoute, | ||
private postService: PageService | ||
) { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './page.service'; | ||
export * from './post.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class PageService { | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
getPageContent(pageId: string) { | ||
return this.http.get(`/content/pages/${pageId}.md`, { responseType: 'text' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="page about-page"> | ||
|
||
## About Me | ||
|
||
<div class="pic"> | ||
<img src="/assets/images/brandonroberts.jpg" width="300" height="300"/> | ||
</div> | ||
|
||
<p class="bio"> | ||
I am an Angular Team member working on guides, tutorials, application development, | ||
and infrastructure for the Angular docs. I enjoys learning new things, helping other | ||
developers solve problems, and contributing to open source. I am also a maintainer of the | ||
NgRx project, building reactive libraries for Angular. | ||
</p> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters