Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

walk the tree of pages to find an index #39

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

root = true


[*]
end_of_line = lf
charset = utf-8
Expand Down
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "8"
- "10"

sudo: false
dist: trusty

addons:
Expand All @@ -27,7 +26,7 @@ branches:
- /^v\d+\.\d+\.\d+/

jobs:
fail_fast: true
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

Expand All @@ -51,8 +50,8 @@ jobs:

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019
Copyright (c) 2020

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ You do not need to be a web developer to be able to use this system. You just wr
Compatibility
------------------------------------------------------------------------------

* Ember.js v3.8 or above
* Ember.js v3.12 or above
* Ember CLI v2.13 or above
* Node.js v8 or above
* Node.js v10 or above

Super Quick Start
------------------------------------------------------------------------------
Expand Down
30 changes: 15 additions & 15 deletions app/routes/version/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ function isExternalRedirect(redirect) {
* @return {[string]} [a normalised path if we think it needs to be normalised]
*/
function normalisePath(path, pages) {
let parts = path.split('/');

let currentPage = pages.find(page => page.id === parts[0]);

// walk the structure of the pages object to find any matching indexes
function walkPages(path, pages) {
if(pages) {
if (pages.find(page => page.url === `${path}/index`)) {
return true;
}

// if the current page is not found then we might be in a redirect file for a
// section that has been removed from the ToC. In this case we're not going to
// be able to normalise the path so just return it without change.
if(!currentPage) {
return path;
// if any of the nested pages have a matching page (recursive)
return pages.find((page) => {
if(page.pages) {
return walkPages(path, page.pages);
}
});
}
}

if (
parts.length === 1
&& currentPage.pages
&& currentPage.pages.find(page => page.url === `${path}/index`)
) {
return `${path}/index`
if(walkPages(path, pages)) {
return `${path}/index`;
}

return path;
Expand Down
8 changes: 4 additions & 4 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ module.exports = async function() {
return {
scenarios: [
{
name: 'ember-lts-3.8',
name: 'ember-lts-3.12',
npm: {
devDependencies: {
'ember-source': '~3.8.0'
'ember-source': '~3.12.0'
}
}
},
{
name: 'ember-lts-3.12',
name: 'ember-lts-3.16',
npm: {
devDependencies: {
'ember-source': '~3.12.0'
'ember-source': '~3.16.0'
}
}
},
Expand Down
Loading