Skip to content

Instantly share code, notes, and snippets.

@ckung
Created June 6, 2017 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckung/79aeb8ba2f24e286b8c7ba6538000f1e to your computer and use it in GitHub Desktop.
Save ckung/79aeb8ba2f24e286b8c7ba6538000f1e to your computer and use it in GitHub Desktop.
diff --git a/app/brands/p4k/models/article.js b/app/brands/p4k/models/article.js
index 90b4d24..bc60e26 100644
--- a/app/brands/p4k/models/article.js
+++ b/app/brands/p4k/models/article.js
@@ -9,6 +9,16 @@ export default BaseArticle.extend({
longformLink: hasMany('externallink', {embedded:true}),
longformUrl: computed.reads('longformLink.firstObject.url'),
+ publishUriHook: computed('categories.sections.[]', function () {
+ let hierarchy = this.get('categories.sections.firstObject._embedded.hierarchy');
+ hierarchy.pop();
+ let categories = hierarchy.map((category) => {
+ return category.fields.slug;
+ });
+ let uri = categories.reverse().join('/');
+ return uri;
+ }),
+
validations: {
channel: {},
categories: {
diff --git a/app/models/publish-data.js b/app/models/publish-data.js
index 2c891b6..317ffad 100644
--- a/app/models/publish-data.js
+++ b/app/models/publish-data.js
@@ -188,7 +188,11 @@ export default Ember.Object.extend(Ember.Validations, AutogeneratorMixin, {
}
}
if (typeof key === 'string' && !Ember.isEmpty(this.get('content.' + key))) {
- uris.push(slugify(this.get('content.' + key)));
+ if (this.get('softSlug')) {
+ uris.push(this.get('content.' + key));
+ } else {
+ uris.push(slugify(this.get('content.' + key)));
+ }
}
}, this);
newPath = uris.join('/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment