-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
libs/publications/feature-this-is-angular/src/lib/article/article.component.ts
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,39 @@ | ||
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core'; | ||
|
||
import { DevCommunityRssItem } from '../dev-community-rss-parser.token'; | ||
|
||
const selector = '[til-article]'; | ||
|
||
@Component({ | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
selector, | ||
template: ` | ||
<h2> | ||
<a [href]="rssItem?.link" target="_blank" rel="nofollow noopener">{{ | ||
rssItem?.title | ||
}}</a> | ||
</h2> | ||
<footer> | ||
<p> | ||
By {{ rssItem?.author }}<br /> | ||
<time [dateTime]="rssItem?.isoDate">{{ | ||
rssItem?.isoDate | date: 'long' | ||
}}</time | ||
><br /> | ||
<span *ngFor="let tag of rssItem?.categories">#{{ tag }} </span> | ||
</p> | ||
</footer> | ||
<p>{{ rssItem?.contentSnippet | tilTruncate }}</p> | ||
<a [href]="rssItem?.link" target="_blank" rel="nofollow noopener" | ||
>Read article</a | ||
> | ||
`, | ||
}) | ||
export class ArticleComponent { | ||
@Input() | ||
rssItem: DevCommunityRssItem | null = null; | ||
} |
12 changes: 12 additions & 0 deletions
12
libs/publications/feature-this-is-angular/src/lib/article/article.scam.ts
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,12 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { TruncateScam } from '../truncate/truncate.scam'; | ||
import { ArticleComponent } from './article.component'; | ||
|
||
@NgModule({ | ||
declarations: [ArticleComponent], | ||
exports: [ArticleComponent], | ||
imports: [CommonModule, TruncateScam], | ||
}) | ||
export class ArticleScam {} |
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
3 changes: 2 additions & 1 deletion
3
libs/publications/feature-this-is-angular/src/lib/shell/shell.scam.ts
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,10 +1,11 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { ArticleScam } from '../article/article.scam'; | ||
import { ShellComponent } from './shell.component'; | ||
|
||
@NgModule({ | ||
declarations: [ShellComponent], | ||
imports: [CommonModule], | ||
imports: [CommonModule, ArticleScam], | ||
}) | ||
export class ShellScam {} |
14 changes: 14 additions & 0 deletions
14
libs/publications/feature-this-is-angular/src/lib/truncate/truncate.pipe.ts
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 { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
@Pipe({ | ||
name: 'tilTruncate', | ||
}) | ||
export class TruncatePipe implements PipeTransform { | ||
transform(text: string | null | undefined): string { | ||
text ??= ''; | ||
|
||
const cutoff = 900; | ||
|
||
return text.length <= cutoff ? text : text.substring(0, cutoff) + ' (...)'; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
libs/publications/feature-this-is-angular/src/lib/truncate/truncate.scam.ts
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,9 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { TruncatePipe } from './truncate.pipe'; | ||
|
||
@NgModule({ | ||
declarations: [TruncatePipe], | ||
exports: [TruncatePipe], | ||
}) | ||
export class TruncateScam {} |