Skip to content

Commit b6e9640

Browse files
committed
Add description meta tag for packages.
1 parent e668505 commit b6e9640

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

app/routes/crate.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,22 @@ export default Ember.Route.extend({
77
return this.controllerFor('application').set('flashError', `Crate '${params.crate_id}' does not exist`);
88
}
99
});
10+
},
11+
12+
afterModel(model) {
13+
this.setHeadTags(model);
14+
},
15+
16+
setHeadTags(model) {
17+
var headTags = [{
18+
type: 'meta',
19+
tagId: 'meta-description-tag',
20+
attrs: {
21+
name: 'description',
22+
content: model.get('description') || 'A package for Rust.'
23+
}
24+
}];
25+
26+
this.set('headTags', headTags);
1027
}
1128
});

app/routes/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import Ember from 'ember';
22
import ajax from 'ic-ajax';
33

44
export default Ember.Route.extend({
5+
headTags: [
6+
{
7+
type: 'meta',
8+
tagId: 'meta-description-tag',
9+
attrs: {
10+
name: 'description',
11+
content: 'Cargo.io: The Rust community’s crate host. Instantly publish your crates and install them. Use the API to interact and find out more information about available crates. Become a contributor and enhance the site with your work.'
12+
}
13+
}
14+
],
15+
516
model() {
617
function addCrates(store, crates) {
718
for (var i = 0; i < crates.length; i++) {

app/templates/head.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<title>{{model.title}}</title>
2+
{{head-tags headTags=model.headTags}}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"ember-cli-ic-ajax": "1.0.0",
3333
"ember-cli-inject-live-reload": "^1.4.0",
3434
"ember-cli-jshint": "^1.0.0",
35+
"ember-cli-meta-tags": "2.0.2",
3536
"ember-cli-mirage": "0.1.13",
3637
"ember-cli-moment-shim": "2.0.0",
3738
"ember-cli-qunit": "3.0.0",

0 commit comments

Comments
 (0)