Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredgalanis authored and Jared Galanis committed Jul 23, 2024
1 parent 9aef35f commit a85cf0c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 42 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.17.1
21 changes: 19 additions & 2 deletions app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export default class ApplicationRoute extends Route {
@service
legacyModuleMappings;

title(tokens) {
let [version, entity] = tokens;
title() {
let entity = this.headData.modelName;
let version = this.headData.modelVersion;
if (!entity) {
entity = 'Ember';
}
Expand All @@ -30,6 +31,22 @@ export default class ApplicationRoute extends Route {
async afterModel() {
set(this, 'headData.cdnDomain', ENV.API_HOST);
await this.legacyModuleMappings.initMappings();

let entity = this.headData.modelName;
let version = this.headData.modelVersion;
if (!entity) {
entity = 'Ember';
}
if (version) {
const compactVersion = getCompactVersion(version);
const title = `${[entity, compactVersion].join(
' - '
)} - Ember API Documentation`;
set(this, 'headData.title', title);
return title;
}
return '';

return super.afterModel(...arguments);
}
}
4 changes: 4 additions & 0 deletions app/routes/project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default class ProjectVersionRoute extends Route {
});
}

afterModel(model) {
this.headData.modelVersion = model.version;
}

// Using redirect instead of afterModel so transition succeeds and returns 307
redirect(model, transition) {
const lookupParams = (routeName) => {
Expand Down
4 changes: 4 additions & 0 deletions app/routes/project-version/classes/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export default class ClassRoute extends Route.extend(ScrollTracker) {
return this.find('class', `${project}-${projectVersion}-${klass}`);
}

afterModel(model) {
this.headData.modelName = model.name;
}

find(typeName, param) {
return this.store.find(typeName, param).catch((e1) => {
if (typeName != 'namespace') {
Expand Down
2 changes: 2 additions & 0 deletions app/routes/project-version/functions/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export default class FunctionRoute extends Route {
if (description) {
set(this, 'headData.description', createExcerpt(description));
}

this.headData.functionName = model?.fn?.name;
}

getFunctionObjFromList(classObj, functionName) {
Expand Down
2 changes: 2 additions & 0 deletions app/services/head-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export default class HeadDataService extends Service {
@tracked canonicalUrl;
@tracked description;
@tracked cdnDomain;
@tracked modelName;
@tracked modelVersion;
}
6 changes: 3 additions & 3 deletions app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<SearchInput />
</EsNavbar>
</EsHeader>
<main class="container">
<main class='container'>
{{outlet}}
</main>
<EsFooter />

{{!-- required by ember-cli-meta-tags --}}
<HeadLayout />
{{! required by ember-cli-meta-tags }}
<HeadLayout />
10 changes: 5 additions & 5 deletions app/templates/head.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<title>{{this.model.title}}</title>

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

{{#if this.model.description}}
<meta name="description" content={{this.model.description}}>
<meta property="og:description" content={{this.model.description}}>
<meta name='description' content={{this.model.description}} />
<meta property='og:description' content={{this.model.description}} />
{{/if}}
{{#unless this.model.isRelease}}
<link rel="canonical" href={{this.model.canonicalUrl}}>
<link rel='canonical' href={{this.model.canonicalUrl}} />
{{/unless}}
33 changes: 2 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
"ember-cli-deploy-gzip": "^1.0.0",
"ember-cli-deprecation-workflow": "^2.1.0",
"ember-cli-fastboot": "^3.3.2",
"ember-cli-head": "^2.0.0",
"ember-cli-htmlbars": "^6.1.1",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-meta-tags": "^7.0.0",
"ember-cli-sass": "^10.0.1",
"ember-cli-terser": "^4.0.2",
"ember-composable-helpers": "^3.1.1",
Expand Down

0 comments on commit a85cf0c

Please sign in to comment.