diff --git a/app/components/route-error.js b/app/components/route-error.js index c3a5099..a69ecaf 100644 --- a/app/components/route-error.js +++ b/app/components/route-error.js @@ -2,25 +2,21 @@ import Ember from 'ember'; import markdownFiles from 'ember-fr-markdown-file/markdownFiles'; const { computed } = Ember; +const excludedPages = ['intro']; export default Ember.Component.extend({ - _parseObj(obj, dir) { - let prefix = dir || ''; - let result = []; - let that = this; - for (let prop in obj) { - let value = obj[prop]; - if (typeof value === 'object') { - result.push(that._parseObj(value, prop)); - } else { - if (prop !== 'intro') { - result.push(`${prefix}/${prop}`.replace(/^\//, '')); - } - } - } - return result; + _parsePages(obj, prefix) { + return Object.keys(obj).map(key => { + const value = obj[key]; + if (typeof value === 'object') { + return this._parsePages(value, key); + } + return prefix ? `${prefix}/${key}` : key; + }) + .reject(p => excludedPages.includes(p)) + .reverse(); }, availablePages: computed(function() { - return [].concat.apply([], this._parseObj(markdownFiles)); + return [].concat.apply([], this._parsePages(markdownFiles)); }) });