Skip to content

Commit

Permalink
Update query format
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien0102 committed Jun 17, 2017
1 parent f17dccb commit 63118de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
16 changes: 9 additions & 7 deletions src/pages/blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface BlogProps {
}

export default (props: BlogProps) => {
const tags = props.data.tags.groupBy;
const tags = props.data.tags.group;
const posts = props.data.posts.edges;
const { pathname } = props.location;
const pageCount = Math.ceil(props.data.posts.totalCount / 10);
Expand Down Expand Up @@ -102,19 +102,21 @@ export default (props: BlogProps) => {
export const pageQuery = graphql`
query PageBlog {
# Get tags
tags: allMarkdownRemark(frontmatter: {draft: {ne: true}}) {
groupBy(field: frontmatter___tags) {
tags: allMarkdownRemark(filter: {frontmatter: {draft: {ne: true}}}) {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
# Get posts
posts: allMarkdownRemark(
sortBy: { order: DESC, fields: [frontmatter___updatedDate] },
frontmatter: { draft: { ne: true } },
fileAbsolutePath: { regex: "/blog/" },
limit: 10,
sort: { order: DESC, fields: [frontmatter___updatedDate] },
filter: {
frontmatter: { draft: { ne: true } },
fileAbsolutePath: { regex: "/blog/" }
},
limit: 10
) {
totalCount
edges {
Expand Down
16 changes: 9 additions & 7 deletions src/templates/blog-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ export default Blog;
export const pageQuery = graphql`
query TemplateBlogPage($skip: Int) {
# Get tags
tags: allMarkdownRemark(frontmatter: {draft: {ne: true}}) {
groupBy(field: frontmatter___tags) {
tags: allMarkdownRemark(filter: {frontmatter: {draft: {ne: true}}}) {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
# Get posts
posts: allMarkdownRemark(
sortBy: { order: DESC, fields: [frontmatter___updatedDate] },
frontmatter: {
draft: { ne: true }
},
fileAbsolutePath: { regex: "/blog/" },
sort: { order: DESC, fields: [frontmatter___updatedDate] },
filter: {
frontmatter: {
draft: { ne: true }
},
fileAbsolutePath: { regex: "/blog/" }
}
limit: 10,
skip: $skip
) {
Expand Down
10 changes: 6 additions & 4 deletions src/templates/blog-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ export const pageQuery = graphql`
}
}
recents: allMarkdownRemark(
fields: {slug: {ne: $slug}},
sortBy: {order: DESC, fields: [frontmatter___updatedDate]},
frontmatter: {draft: {ne: true}},
fileAbsolutePath: {regex: "/blog/"},
filter: {
fields: {slug: {ne: $slug}}
frontmatter: {draft: {ne: true}},
fileAbsolutePath: {regex: "/blog/"},
},
sort: {order: DESC, fields: [frontmatter___updatedDate]},
limit: 4
) {
edges {
Expand Down
18 changes: 10 additions & 8 deletions src/templates/tags-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@ export default Blog;
export const pageQuery = graphql`
query TemplateTagPage($tag: String) {
# Get tags
tags: allMarkdownRemark(frontmatter: {draft: {ne: true}}) {
groupBy(field: frontmatter___tags) {
tags: allMarkdownRemark(filter: {frontmatter: {draft: {ne: true}}}) {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
# Get posts
posts: allMarkdownRemark(
sortBy: { order: DESC, fields: [frontmatter___updatedDate] },
frontmatter: {
draft: { ne: true }
tags: { in: [$tag] }
},
fileAbsolutePath: { regex: "/blog/" },
sort: { order: DESC, fields: [frontmatter___updatedDate] },
filter: {
frontmatter: {
draft: { ne: true }
tags: { in: [$tag] }
},
fileAbsolutePath: { regex: "/blog/" }
}
) {
totalCount
edges {
Expand Down

0 comments on commit 63118de

Please sign in to comment.