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 4704659 commit fcdefc5
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 247 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);

Check failure on line 50 in app/routes/application.js

View workflow job for this annotation

GitHub Actions / Lint files

Unreachable code
}
}
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}}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"ember-cli-deploy-gzip": "^1.0.0",
"ember-cli-deprecation-workflow": "^2.1.0",
"ember-cli-fastboot": "^4.1.5",
"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-showdown": "^9.0.1",
"ember-cli-terser": "^4.0.2",
Expand Down
Loading

0 comments on commit fcdefc5

Please sign in to comment.