Repository: ProjectEvergreen/greenwood (js)

Issue:
filter out parent page from ChildrenQuery response
## Type of Change
- [ ] New Feature Request
- [ ] Documentation / Website
- [x] Improvement / Suggestion
- [ ] Bug
- [ ] Other (please clarify below)

## Summary
Right now `ChildrenQuery` is returning the [index.md](https://github.com/ProjectEvergreen/greenwood/blob/release/0.5.0/packages/cli/test/unit/data/schema/graph.spec.js#L68) as part of the array of pages returned, which is effectively the parent route.  I think in this case, it doesn't make sense to return the parent if you are asking for the children, or else to render the children as a list, you'll have to exclude the parent, e.g. _${parent}/index.md_


So effectively the resolver should just filter out _index.md_ then.

## Details
Given a structure like this
```shell
pages/
  blog/
    first-post.md
    index.md
    second-post.md
    third-post.md
```

And render it like this
```js
render() {
  return html`
    <ul>
      ${posts.map((post) => {
        return html`
          <li>
            <a href="${post.link}" title="Click to read my ${post.title} blog post">${post.title}</a>
          </li>
        `;
       })}
     </ul>
  `
}
```

You'll have to something like this in your component
```js
class BlogPostsTemplate extends LitElement {
  ...
  
  async connectedCallback() {
    super.connectedCallback();
    const response = await client.query({
      query: ChildrenQuery,
      variables: {
        parent: 'blog'
      }
    });

    this.posts = response.data.children.filter(post => {
      return post.filePath.indexOf('/blog/index') < 0;
    });
  }
```

Or else you'll have a list like this, when you probably only want the posts themselves
1. First Post
1. Blog
1. Second Post
1. Third Post

Pull request:
filter out index page from children query
<!--
## Submitting a Pull Request
We love contributions and appreciate any help you can offer!
-->

## Related Issue
resolves #332 

## Summary of Changes
1. Exclude  parent page from `getChildrenFromParentRoute` call
1. Update Specs

## TODO
1. [x] Wait until #383 is merged, then remove need to [filter here](https://github.com/ProjectEvergreen/greenwood/blob/v0.7.2/packages/cli/test/cases/build.data.graph/src/templates/blog-template.js) (which should still allow the test to pass and further confirm the implementation here)

Patch:
diff --git a/packages/cli/src/data/schema/graph.js b/packages/cli/src/data/schema/graph.js
index 1c1c51a2..f5a74b73 100644
--- a/packages/cli/src/data/schema/graph.js
+++ b/packages/cli/src/data/schema/graph.js
@@ -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({


Test patch:
diff --git a/packages/cli/test/cases/build.data.graph/src/templates/blog-template.js b/packages/cli/test/cases/build.data.graph/src/templates/blog-template.js
index 110338c6..5a0e50b1 100644
--- a/packages/cli/test/cases/build.data.graph/src/templates/blog-template.js
+++ b/packages/cli/test/cases/build.data.graph/src/templates/blog-template.js
@@ -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 */
diff --git a/packages/cli/test/unit/data/schema/graph.spec.js b/packages/cli/test/unit/data/schema/graph.spec.js
index 3448ec8a..c33792d6 100644
--- a/packages/cli/test/unit/data/schema/graph.spec.js
+++ b/packages/cli/test/unit/data/schema/graph.spec.js
@@ -39,25 +39,22 @@ 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}`);
           });
         });
 
@@ -65,11 +62,10 @@ describe('Unit Test: Data', 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() {
@@ -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() {