-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor to seo-service. make it so search results cannot be indexed
- Loading branch information
Showing
4 changed files
with
88 additions
and
24 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { inject, Injectable } from '@angular/core'; | ||
|
||
import { Meta, Title } from '@angular/platform-browser'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class SEOService { | ||
private pageMeta = inject(Meta); | ||
private title = inject(Title); | ||
|
||
public updateOGTitle(newTitle: string): void { | ||
this.pageMeta.updateTag({ property: 'og:title', content: newTitle }); | ||
} | ||
|
||
public updateOGImage(newImage: string): void { | ||
this.pageMeta.updateTag({ property: 'og:image', content: newImage }); | ||
} | ||
|
||
public updateOGDescription(newDesc: string): void { | ||
this.pageMeta.updateTag({ | ||
property: 'og:description', | ||
content: newDesc, | ||
}); | ||
} | ||
|
||
public updateOGURL(newURL: string): void { | ||
this.pageMeta.updateTag({ | ||
property: 'og:url', | ||
content: newURL, | ||
}); | ||
} | ||
|
||
public updatePageTitle(newTitle: string): void { | ||
this.title.setTitle(newTitle); | ||
} | ||
|
||
public updateMetaDescription(newDesc: string): void { | ||
this.pageMeta.updateTag({ | ||
name: 'description', | ||
content: newDesc, | ||
}); | ||
} | ||
|
||
public makePageIndexable() { | ||
this.pageMeta.removeTag('property="robots"'); | ||
} | ||
|
||
public makePageUnindexable() { | ||
this.pageMeta.addTag({ property: 'robots', content: 'noindex' }); | ||
} | ||
} |