Skip to content

Commit df85f4c

Browse files
author
Salma Alam-Naylor
committed
Update all OG meta
1 parent 679e11f commit df85f4c

File tree

5 files changed

+75
-10
lines changed

5 files changed

+75
-10
lines changed

apps/fretonator-web/src/app/common/meta/meta.service.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ describe('MetaService', () => {
1515
expect(metaService).toBeTruthy();
1616
});
1717

18+
it('should return the base title', () => {
19+
const result = metaService.getBaseTitle();
20+
expect(result).toBe('Fretonator - the ultimate interactive free guitar theory tool');
21+
})
22+
23+
it('should return a generic end description', () => {
24+
const result = metaService.getGenericEndDescription();
25+
expect(result).toBe('Choose a starting note, pick a mode, check out the fretboard and have a jam!')
26+
})
27+
28+
it('should return a home page url from given parameters', () => {
29+
const result = metaService.generateHomePageUrl('c', 'natural', 'lydian');
30+
expect(result).toBe('https://www.fretonator.com/c/natural/lydian');
31+
})
32+
1833
it('should call the fret map service for the title and return the correct string', () => {
1934
const result = metaService.generateHomePageTitle('c', 'natural', 'lydian');
2035
expect(result).toBe('Fretonator - the ultimate interactive free guitar theory tool | C Lydian');

apps/fretonator-web/src/app/common/meta/meta.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ export class MetaService {
1515

1616
getGenericEndDescription = (): string => {
1717
return 'Choose a starting note, pick a mode, check out the fretboard and have a jam!';
18-
}
18+
};
19+
20+
generateHomePageUrl = (note,
21+
noteExtenderString,
22+
mode): string => {
23+
return 'https://www.fretonator.com/' + note + '/' + noteExtenderString + '/' + mode;
24+
};
1925

2026
generateHomePageTitle = (note,
2127
noteExtenderString,

apps/fretonator-web/src/app/pages/about/about-index/about-index.component.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,38 @@ import { Meta, Title } from '@angular/platform-browser';
77
styleUrls: ['./about-index.component.scss']
88
})
99
export class AboutIndexComponent implements OnInit {
10+
pageDescription = 'Thanks for checking out the Fretonator! I’m a qualified music teacher that (somehow) ended up working as a lead software engineer (it’s a long story), and I built this for my husband.';
11+
pageTitle = 'About the Fretonator - the ultimate interactive free guitar theory tool';
12+
pageUrl = 'https://www.fretonator.com/about'
13+
1014
constructor(private title: Title, private meta: Meta) {
1115
}
1216

1317
ngOnInit(): void {
14-
this.title.setTitle('About the Fretonator - the ultimate interactive free guitar theory tool');
18+
this.title.setTitle(this.pageTitle);
1519
this.meta.updateTag({
1620
name: 'description',
17-
content: "Thanks for checking out the Fretonator! I’m a qualified music teacher that (somehow) ended up working as a lead software engineer (it’s a long story), and I built this for my husband."
21+
content: this.pageDescription
22+
});
23+
24+
this.meta.updateTag({
25+
property: 'og:url',
26+
content: this.pageUrl
27+
});
28+
29+
this.meta.updateTag({
30+
name: 'twitter:description',
31+
content: this.pageDescription
32+
});
33+
34+
this.meta.updateTag({
35+
property: 'og:description',
36+
content: this.pageDescription
37+
});
38+
39+
this.meta.updateTag({
40+
property: 'og:title',
41+
content: this.pageTitle
1842
});
1943
}
2044
}

apps/fretonator-web/src/app/pages/home/home-index/home-index.component.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class HomeIndexComponent implements OnInit {
2121
modeSelectorObjects = ModeSelectorObjects;
2222
octave = Octave;
2323
showHowTo;
24-
24+
2525
constructor(
2626
private title: Title,
2727
private meta: Meta,
@@ -35,7 +35,7 @@ export class HomeIndexComponent implements OnInit {
3535
ngOnInit(): void {
3636
this.activatedRoute.params.subscribe(() => this.onRouteChange());
3737
this.setHomePageTitle();
38-
this.setHomePageMetaDescription();
38+
this.setHomePageMeta();
3939

4040
const _showHowTo = this.localStorage.getItem('showHowTo');
4141
switch (_showHowTo) {
@@ -70,7 +70,7 @@ export class HomeIndexComponent implements OnInit {
7070
}
7171

7272
this.setHomePageTitle();
73-
this.setHomePageMetaDescription();
73+
this.setHomePageMeta();
7474
}
7575

7676
toggleHowTo() {
@@ -84,10 +84,30 @@ export class HomeIndexComponent implements OnInit {
8484
);
8585
}
8686

87-
setHomePageMetaDescription() {
87+
setHomePageMeta() {
8888
this.meta.updateTag({
8989
name: 'description',
9090
content: this.metaService.generateHomePageMetaDescription(this.note, this.noteExtenderString, this.mode)
9191
});
92+
93+
this.meta.updateTag({
94+
name: 'twitter:description',
95+
content: this.metaService.generateHomePageMetaDescription(this.note, this.noteExtenderString, this.mode)
96+
});
97+
98+
this.meta.updateTag({
99+
property: 'og:description',
100+
content: this.metaService.generateHomePageMetaDescription(this.note, this.noteExtenderString, this.mode)
101+
});
102+
103+
this.meta.updateTag({
104+
property: 'og:title',
105+
content: this.metaService.generateHomePageTitle(this.note, this.noteExtenderString, this.mode)
106+
});
107+
108+
this.meta.updateTag({
109+
property: 'og:url',
110+
content: this.metaService.generateHomePageUrl(this.note, this.noteExtenderString, this.mode)
111+
});
92112
}
93113
}

apps/fretonator-web/src/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8"/>
5-
<title>Fretonator</title>
6-
<base href="/"/>
75
<meta name="viewport" content="width=device-width, initial-scale=1"/>
6+
<base href="/"/>
7+
<title>Fretonator - the ultimate interactive free guitar theory tool</title>
8+
<meta name="description" content="Choose a starting note, pick a mode, check out the fretboard and have a jam!">
89
<meta property="og:type" content="website">
910
<meta property="og:title" content="Fretonator - the ultimate free guitar theory tool"/>
1011
<meta property="og:description"
@@ -26,7 +27,6 @@
2627
<link rel="manifest" href="manifest.webmanifest">
2728
<meta name="theme-color" content="#1a1a1a">
2829

29-
3030
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-167450036-1"></script>
3131
<script>
3232
window.dataLayer = window.dataLayer || [];

0 commit comments

Comments
 (0)