-
Notifications
You must be signed in to change notification settings - Fork 78
Adding BreadcrumbList schema.org spec #119
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import layout from '../templates/components/bread-crumbs'; | |
|
||
const { | ||
get, | ||
set, | ||
Component, | ||
computed, | ||
copy, | ||
|
@@ -13,6 +14,7 @@ const { | |
typeOf, | ||
setProperties, | ||
getOwner, | ||
LinkComponent, | ||
A: emberArray, | ||
String: { classify } | ||
} = Ember; | ||
|
@@ -26,11 +28,29 @@ export default Component.extend({ | |
tagName: 'ol', | ||
linkable: true, | ||
reverse: false, | ||
hasSchema: false, | ||
classNameBindings: ['breadCrumbClass'], | ||
attributeBindings: [], | ||
itemscope: true, | ||
itemtype: 'http://schema.org/BreadcrumbList', | ||
hasBlock: bool('template').readOnly(), | ||
currentUrl: readOnly('applicationRoute.router.url'), | ||
currentRouteName: readOnly('applicationRoute.controller.currentRouteName'), | ||
|
||
init() { | ||
this._super(...arguments); | ||
|
||
LinkComponent.reopen({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to reopen the Also to make this backward compatible we need a version flag to switch to Do you have thoughts about? |
||
attributeBindings: ['itemscope', 'itemtype', 'itemprop'] | ||
}); | ||
|
||
if (get(this, 'hasSchema')) { | ||
const newAttributeBindings = ['itemscope', 'itemtype']; | ||
|
||
set(this, 'attributeBindings', this.attributeBindings.concat(newAttributeBindings)); | ||
} | ||
}, | ||
|
||
routeHierarchy: computed('currentUrl', 'currentRouteName', 'reverse', { | ||
get() { | ||
const currentRouteName = getWithDefault(this, 'currentRouteName', false); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
{{#if route.linkable}} | ||
{{#link-to route.path class=linkClass}} | ||
{{#if hasBlock}} | ||
{{yield this route}} | ||
{{else}} | ||
{{route.title}} | ||
{{/if}} | ||
{{#link-to route.path class=linkClass itemscope=true itemtype="http://schema.org/Thing" itemprop="item"}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI These attrs it the Have you thought about using the |
||
{{#if hasBlock}} | ||
{{yield this route}} | ||
{{else}} | ||
{{#if hasSchema}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could make one more component to clean up this level of nest ifs |
||
<span itemprop="name"> | ||
{{route.title}} | ||
</span> | ||
{{else}} | ||
{{route.title}} | ||
{{/if}} | ||
{{/if}} | ||
{{/link-to}} | ||
{{#if hasSchema}} | ||
<meta itemprop="position" content={{position}}> | ||
{{/if}} | ||
{{else}} | ||
{{#if hasBlock}} | ||
{{yield this route}} | ||
{{else}} | ||
{{route.title}} | ||
{{#if hasSchema}} | ||
<span itemprop="name"> | ||
{{route.title}} | ||
</span> | ||
<meta itemprop="position" content={{position}}> | ||
{{else}} | ||
{{route.title}} | ||
{{/if}} | ||
{{/if}} | ||
{{/if}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{{#each routeHierarchy as |route|}} | ||
{{#each routeHierarchy as |route index|}} | ||
{{#if hasBlock}} | ||
{{yield this route}} | ||
{{else}} | ||
{{bread-crumb route=route breadCrumbs=this}} | ||
{{bread-crumb route=route breadCrumbs=this index=index}} | ||
{{/if}} | ||
{{/each}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to do this in two places we could move it a mixin.