Skip to content

Commit

Permalink
filter out index page from children query
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Jul 22, 2020
1 parent 7bbdb17 commit 8806039
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/data/schema/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const getChildrenFromParentRoute = async (root, query, context) => {
const { label } = getDeriveMetaFromRoute(route);
const root = route.split('/')[1];

if (root.indexOf(parent) >= 0) {
if (root.indexOf(parent) >= 0 && page.fileName !== 'index') {
const id = page.label;

pages.push({
Expand Down
33 changes: 14 additions & 19 deletions packages/cli/test/unit/data/schema/graph.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,33 @@ describe('Unit Test: Data', function() {
});

it('should have 8 children', function() {
expect(children.length).to.equal(8);
expect(children.length).to.equal(7);
});

it('should have the expected value for id for each child', function() {
expect(children[0].id).to.equal('css-components');
expect(children[1].id).to.equal('deploy');
expect(children[2].id).to.equal('create-content');
expect(children[3].id).to.equal('getting-started');
expect(children[4].id).to.equal('concepts');
expect(children[5].id).to.equal('next');
expect(children[6].id).to.equal('project-setup');
expect(children[7].id).to.equal('start');
expect(children[3].id).to.equal('concepts');
expect(children[4].id).to.equal('next');
expect(children[5].id).to.equal('project-setup');
expect(children[6].id).to.equal('start');
});

it('should have the expected filePath for each child', function() {
children.forEach(function(child) {
const path = child.fileName === 'index' ? '' : child.fileName;

expect(child.link).to.equal(`/getting-started/${path}`);
expect(child.link).to.equal(`/getting-started/${child.fileName}`);
});
});

it('should have the expected fileName for each child', function() {
expect(children[0].fileName).to.equal('branding');
expect(children[1].fileName).to.equal('build-and-deploy');
expect(children[2].fileName).to.equal('creating-content');
expect(children[3].fileName).to.equal('index');
expect(children[4].fileName).to.equal('key-concepts');
expect(children[5].fileName).to.equal('next-steps');
expect(children[6].fileName).to.equal('project-setup');
expect(children[7].fileName).to.equal('quick-start');
expect(children[3].fileName).to.equal('key-concepts');
expect(children[4].fileName).to.equal('next-steps');
expect(children[5].fileName).to.equal('project-setup');
expect(children[6].fileName).to.equal('quick-start');
});

it('should have the expected link for each child', function() {
Expand All @@ -88,11 +84,10 @@ describe('Unit Test: Data', function() {
expect(children[0].title).to.equal('Styles and Web Components');
expect(children[1].title).to.equal('Build and Deploy');
expect(children[2].title).to.equal('Creating Content');
expect(children[3].title).to.equal('Getting Started');
expect(children[4].title).to.equal('Key Concepts');
expect(children[5].title).to.equal('Next Steps');
expect(children[6].title).to.equal('Project Setup');
expect(children[7].title).to.equal('Quick Start');
expect(children[3].title).to.equal('Key Concepts');
expect(children[4].title).to.equal('Next Steps');
expect(children[5].title).to.equal('Project Setup');
expect(children[6].title).to.equal('Quick Start');
});

it('should have expected custom front matter data if it is set', function() {
Expand Down

0 comments on commit 8806039

Please sign in to comment.