-
Notifications
You must be signed in to change notification settings - Fork 0
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
9 changed files
with
90 additions
and
49 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 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,43 +1,8 @@ | ||
import { DOCUMENT } from '@angular/common'; | ||
import { Component, Inject, OnDestroy, OnInit, Renderer2 } from '@angular/core'; | ||
import { Subject, takeUntil } from 'rxjs'; | ||
import { AppService } from '../app.service'; | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-about', | ||
templateUrl: './about.component.html', | ||
styleUrls: ['./about.component.scss'], | ||
}) | ||
export class AboutComponent implements OnInit, OnDestroy { | ||
private onDestroy$: Subject<boolean> = new Subject<boolean>(); | ||
constructor( | ||
public appService: AppService, | ||
@Inject(DOCUMENT) private document: Document, | ||
private renderer: Renderer2 | ||
) {} | ||
|
||
ngOnInit(): void { | ||
const script = this.renderer.createElement('script'); | ||
|
||
this.appService.theme$ | ||
.pipe(takeUntil(this.onDestroy$)) | ||
.subscribe((theme) => { | ||
script.type = 'text/javascript'; | ||
script.src = 'https://utteranc.es/client.js'; | ||
script.setAttribute('repo', 'mtwmt/ironman'); | ||
script.setAttribute('issue-term', 'pathname'); | ||
script.setAttribute('theme', !theme ? 'github-light' : 'github-dark'); | ||
script.setAttribute('crossorigin', 'anonymous'); | ||
script.text = ``; | ||
this.renderer.appendChild( | ||
this.document.querySelector('#comments'), | ||
script | ||
); | ||
}); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.onDestroy$.next(false); | ||
this.onDestroy$.complete(); | ||
} | ||
} | ||
export class AboutComponent {} |
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,3 @@ | ||
|
||
<p class="text-center text-lg">有任何想法與建議歡迎留言給我哦!</p> | ||
<div class="w-full" id="comments"></div> |
Empty file.
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,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { CommentsComponent } from './comments.component'; | ||
|
||
describe('CommentsComponent', () => { | ||
let component: CommentsComponent; | ||
let fixture: ComponentFixture<CommentsComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [CommentsComponent] | ||
}); | ||
fixture = TestBed.createComponent(CommentsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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,45 @@ | ||
import { DOCUMENT } from '@angular/common'; | ||
import { | ||
Component, | ||
DestroyRef, | ||
Inject, | ||
OnInit, | ||
Renderer2, | ||
inject, | ||
} from '@angular/core'; | ||
import { AppService } from '../app.service'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
|
||
@Component({ | ||
selector: 'app-comments', | ||
templateUrl: './comments.component.html', | ||
styleUrls: ['./comments.component.scss'], | ||
}) | ||
export class CommentsComponent implements OnInit { | ||
destroyRef = inject(DestroyRef); | ||
|
||
constructor( | ||
public appService: AppService, | ||
@Inject(DOCUMENT) private document: Document, | ||
private renderer: Renderer2 | ||
) {} | ||
|
||
ngOnInit(): void { | ||
const script = this.renderer.createElement('script'); | ||
this.appService.theme$ | ||
.pipe(takeUntilDestroyed(this.destroyRef)) | ||
.subscribe((theme) => { | ||
script.type = 'text/javascript'; | ||
script.src = 'https://utteranc.es/client.js'; | ||
script.setAttribute('repo', 'mtwmt/ironman'); | ||
script.setAttribute('issue-term', 'pathname'); | ||
script.setAttribute('theme', !theme ? 'github-light' : 'github-dark'); | ||
script.setAttribute('crossorigin', 'anonymous'); | ||
script.text = ``; | ||
this.renderer.appendChild( | ||
this.document.querySelector('#comments'), | ||
script | ||
); | ||
}); | ||
} | ||
} |
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
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