Skip to content

Commit

Permalink
filter out index page from children query (#388)
Browse files Browse the repository at this point in the history
* filter out index page from children query

* adjust logic for filter parent pages

* remove index filter
  • Loading branch information
thescientist13 authored Jul 25, 2020
1 parent 4a9b1ac commit 2a6238e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 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 && mdFile !== `./${parent}/index.md`) {
const id = page.label;

pages.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class BlogTemplate extends LitElement {
}
});

this.posts = response.data.children.filter(post => {
return post.filePath.indexOf('/blog/index') < 0;
});
this.posts = response.data.children;
}

/* eslint-disable indent */
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 2a6238e

Please sign in to comment.