Skip to content

Commit 78733a7

Browse files
jaredgalanisJared Galanis
authored and
Jared Galanis
committed
wip
1 parent 4704659 commit 78733a7

File tree

9 files changed

+41
-11
lines changed

9 files changed

+41
-11
lines changed

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 18.17.1

app/routes/application.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export default class ApplicationRoute extends Route {
1111
@service
1212
legacyModuleMappings;
1313

14-
title(tokens) {
15-
let [version, entity] = tokens;
14+
title() {
15+
let entity = this.headData.modelName;
16+
let version = this.headData.modelVersion;
1617
if (!entity) {
1718
entity = 'Ember';
1819
}
@@ -30,6 +31,22 @@ export default class ApplicationRoute extends Route {
3031
async afterModel() {
3132
set(this, 'headData.cdnDomain', ENV.API_HOST);
3233
await this.legacyModuleMappings.initMappings();
34+
35+
let entity = this.headData.modelName;
36+
let version = this.headData.modelVersion;
37+
if (!entity) {
38+
entity = 'Ember';
39+
}
40+
if (version) {
41+
const compactVersion = getCompactVersion(version);
42+
const title = `${[entity, compactVersion].join(
43+
' - '
44+
)} - Ember API Documentation`;
45+
set(this, 'headData.title', title);
46+
return title;
47+
}
48+
return '';
49+
3350
return super.afterModel(...arguments);
3451
}
3552
}

app/routes/project-version.js

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export default class ProjectVersionRoute extends Route {
4343
});
4444
}
4545

46+
afterModel(model) {
47+
this.headData.modelVersion = model.version;
48+
}
49+
4650
// Using redirect instead of afterModel so transition succeeds and returns 307
4751
redirect(model, transition) {
4852
const lookupParams = (routeName) => {

app/routes/project-version/classes/class.js

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export default class ClassRoute extends Route.extend(ScrollTracker) {
3636
return this.find('class', `${project}-${projectVersion}-${klass}`);
3737
}
3838

39+
afterModel(model) {
40+
this.headData.modelName = model.name;
41+
}
42+
3943
find(typeName, param) {
4044
return this.store.find(typeName, param).catch((e1) => {
4145
if (typeName != 'namespace') {

app/routes/project-version/functions/function.js

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export default class FunctionRoute extends Route {
5656
if (description) {
5757
set(this, 'headData.description', createExcerpt(description));
5858
}
59+
60+
this.headData.functionName = model?.fn?.name;
5961
}
6062

6163
getFunctionObjFromList(classObj, functionName) {

app/services/head-data.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ export default class HeadDataService extends Service {
99
@tracked canonicalUrl;
1010
@tracked description;
1111
@tracked cdnDomain;
12+
@tracked modelName;
13+
@tracked modelVersion;
1214
}

app/templates/application.hbs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<SearchInput />
44
</EsNavbar>
55
</EsHeader>
6-
<main class="container">
6+
<main class='container'>
77
{{outlet}}
88
</main>
99
<EsFooter />
1010

11-
{{!-- required by ember-cli-meta-tags --}}
12-
<HeadLayout />
11+
{{! required by ember-cli-meta-tags }}
12+
<HeadLayout />

app/templates/head.hbs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<title>{{this.model.title}}</title>
22

3-
<link rel="dns-prefetch" href="{{this.model.cdnDomain}}">
4-
<meta property="og:title" content={{this.model.title}}>
3+
<link rel='dns-prefetch' href='{{this.model.cdnDomain}}' />
4+
<meta property='og:title' content={{this.model.title}} />
55

66
{{#if this.model.description}}
7-
<meta name="description" content={{this.model.description}}>
8-
<meta property="og:description" content={{this.model.description}}>
7+
<meta name='description' content={{this.model.description}} />
8+
<meta property='og:description' content={{this.model.description}} />
99
{{/if}}
1010
{{#unless this.model.isRelease}}
11-
<link rel="canonical" href={{this.model.canonicalUrl}}>
11+
<link rel='canonical' href={{this.model.canonicalUrl}} />
1212
{{/unless}}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
"ember-cli-deploy-gzip": "^1.0.0",
7979
"ember-cli-deprecation-workflow": "^2.1.0",
8080
"ember-cli-fastboot": "^4.1.5",
81+
"ember-cli-head": "^2.0.0",
8182
"ember-cli-htmlbars": "^6.1.1",
8283
"ember-cli-inject-live-reload": "^2.1.0",
83-
"ember-cli-meta-tags": "^7.0.0",
8484
"ember-cli-sass": "^10.0.1",
8585
"ember-cli-showdown": "^9.0.1",
8686
"ember-cli-terser": "^4.0.2",

0 commit comments

Comments
 (0)