From 7350ccdb8918315be7cd8034a57e9eff7cc6e6a7 Mon Sep 17 00:00:00 2001 From: samaradel Date: Mon, 22 Feb 2021 12:06:33 +0200 Subject: [PATCH] Add filter --- gridsome.server.js | 170 ++++++++++++++++++------------------- src/pages/Blog.vue | 2 +- src/pages/News.vue | 4 +- src/templates/Partners.vue | 7 +- src/templates/Project.vue | 2 +- src/templates/Projects.vue | 2 +- src/templates/Search.vue | 2 +- src/templates/Tag.vue | 2 +- 8 files changed, 97 insertions(+), 94 deletions(-) diff --git a/gridsome.server.js b/gridsome.server.js index b44b64dbd..1ccd50f81 100644 --- a/gridsome.server.js +++ b/gridsome.server.js @@ -61,13 +61,13 @@ module.exports = function(api) { }); api.createPages(async({ - graphql, - createPage - }) => { - // Use the Pages API here: https://gridsome.org/docs/pages-api - const { - data - } = await graphql(`{ + graphql, + createPage + }) => { + // Use the Pages API here: https://gridsome.org/docs/pages-api + const { + data + } = await graphql(`{ allNews { edges { previous { @@ -85,25 +85,25 @@ module.exports = function(api) { } `); - data.allNews.edges.forEach(function(element) { - createPage({ - path: element.node.path, - component: './src/templates/NewsPost.vue', - context: { - previousElement: (element.previous) ? element.previous.id : '##empty##', - nextElement: (element.next) ? element.next.id : '##empty##', - id: element.node.id - } - }); + data.allNews.edges.forEach(function(element) { + createPage({ + path: element.node.path, + component: './src/templates/NewsPost.vue', + context: { + previousElement: (element.previous) ? element.previous.id : '##empty##', + nextElement: (element.next) ? element.next.id : '##empty##', + id: element.node.id + } + }); - }); + }); - }); + }); - api.createPages(async ({ graphql, createPage }) => { - const { data } = await graphql(`{ - allProjectTag(filter: { title: {in: ["farming"]}}) { - edges { + api.createPages(async({ graphql, createPage }) => { + const { data } = await graphql(`{ + allProjectTag(filter: { title: {in: ["tech", "foundation"]}}) { + edges { node { id path @@ -112,20 +112,20 @@ module.exports = function(api) { } }`) - data.allProjectTag.edges.forEach(({ node }) => { - createPage({ - path: `${node.path}`, - component: './src/templates/Tag.vue', - context: { - id: node.id, - private: private - } - }) + data.allProjectTag.edges.forEach(({ node }) => { + createPage({ + path: `${node.path}`, + component: './src/templates/Tag.vue', + context: { + id: node.id, + private: private + } + }) + }) }) - }) - api.createPages(async ({ graphql, createPage }) => { - const { data } = await graphql(`{ + api.createPages(async({ graphql, createPage }) => { + const { data } = await graphql(`{ allBlogTag { edges { node { @@ -136,20 +136,20 @@ module.exports = function(api) { } }`) - data.allBlogTag.edges.forEach(({ node }) => { - createPage({ - path: `${node.path}`, - component: './src/templates/Tag.vue', - context: { - id: node.id, - private: private - } - }) + data.allBlogTag.edges.forEach(({ node }) => { + createPage({ + path: `${node.path}`, + component: './src/templates/Tag.vue', + context: { + id: node.id, + private: private + } + }) + }) }) - }) - api.createPages(async ({ graphql, createPage }) => { - const { data } = await graphql(`{ + api.createPages(async({ graphql, createPage }) => { + const { data } = await graphql(`{ allNewsTag { edges { node { @@ -160,47 +160,47 @@ module.exports = function(api) { } }`) - data.allNewsTag.edges.forEach(({ node }) => { - createPage({ - path: `${node.path}`, - component: './src/templates/Tag.vue', - context: { - id: node.id, - private: private - } - }) + data.allNewsTag.edges.forEach(({ node }) => { + createPage({ + path: `${node.path}`, + component: './src/templates/Tag.vue', + context: { + id: node.id, + private: private + } + }) + }) }) - }) - api.createPages(({ createPage }) => { - createPage({ - path: '/partners', - component: './src/templates/Partners.vue', - context: { - private: private - } + api.createPages(({ createPage }) => { + createPage({ + path: '/partners', + component: './src/templates/Partners.vue', + context: { + private: private + } + }) }) -}) -api.createPages(({ createPage }) => { - createPage({ - path: '/team', - component: './src/templates/Team.vue', - context: { - private: private - } - }) -}); + api.createPages(({ createPage }) => { + createPage({ + path: '/team', + component: './src/templates/Team.vue', + context: { + private: private + } + }) + }); + + api.createPages(({ createPage }) => { + createPage({ + path: '/search', + component: './src/templates/Search.vue', + context: { + private: private + } + }) + }); + -api.createPages(({ createPage }) => { - createPage({ - path: '/search', - component: './src/templates/Search.vue', - context: { - private: private - } - }) -}); - - } \ No newline at end of file diff --git a/src/pages/Blog.vue b/src/pages/Blog.vue index 5b0c96544..a41bcc07c 100644 --- a/src/pages/Blog.vue +++ b/src/pages/Blog.vue @@ -36,7 +36,7 @@ query($page: Int){ - entries: allBlog(perPage: 10, page: $page, sortBy: "created", order: DESC, filter: {category: { id: {in: ["farming"]}}}) @paginate{ + entries: allBlog(perPage: 10, page: $page, sortBy: "created", order: DESC, filter: {category: { id: {in: ["tech", "foundation"]}}}) @paginate{ totalCount pageInfo { totalPages diff --git a/src/pages/News.vue b/src/pages/News.vue index b2769fc67..15ec38871 100644 --- a/src/pages/News.vue +++ b/src/pages/News.vue @@ -40,7 +40,7 @@ query($page: Int){ - entries: allNews(perPage: 10, page: $page, sortBy: "created", order: DESC, filter: {category: { id: {in: ["farming"]}}}) @paginate{ + entries: allNews(perPage: 10, page: $page, sortBy: "created", order: DESC, filter: {category: { id: {in: ["tech", "foundation"]}}}) @paginate{ totalCount pageInfo { totalPages @@ -67,7 +67,7 @@ query($page: Int){ } } - topics: allNewsTag{ + topics: allNewsTag { edges{ node{ title diff --git a/src/templates/Partners.vue b/src/templates/Partners.vue index e2623113b..6601b8833 100644 --- a/src/templates/Partners.vue +++ b/src/templates/Partners.vue @@ -16,7 +16,7 @@ query ($private: Int){ - entries: allProject (sortBy: "rank", order: DESC, filter: { private: { ne: $private }, tags: { id: {in: ["farming"]}}}){ + entries: allProject (sortBy: "rank", order: DESC, filter: { private: { ne: $private }, tags: { id: {in: ["tech", "foundation"]}}}){ totalCount edges { node { @@ -39,7 +39,7 @@ query ($private: Int){ } } - tags: allProjectTag (filter: { title: {in: ["farming"]}}) { + tags: allProjectTag (filter: { title: {in: ["tech", "foundation"]}}) { edges{ node{ id @@ -70,5 +70,8 @@ export default { return res; }, }, + mounted(){ + console.log(this.$page) + } }; diff --git a/src/templates/Project.vue b/src/templates/Project.vue index 8f553ce2d..13fdb4e21 100644 --- a/src/templates/Project.vue +++ b/src/templates/Project.vue @@ -136,7 +136,7 @@ } } - tags: allProjectTag (filter: { title: {in: ["farming"]}}) { + tags: allProjectTag (filter: { title: {in: ["tech", "foundation"]}}) { edges{ node{ id diff --git a/src/templates/Projects.vue b/src/templates/Projects.vue index bd6170bba..4f1247bc2 100644 --- a/src/templates/Projects.vue +++ b/src/templates/Projects.vue @@ -18,7 +18,7 @@ query ($private: Int){ - entries: allProject (sortBy: "rank", order: DESC, filter: { private: { ne: $private }}){ + entries: allProject (sortBy: "rank", order: DESC, filter: { private: { ne: $private }}, tags: { id: {in: ["tech", "foundation"]}}){ totalCount edges { node { diff --git a/src/templates/Search.vue b/src/templates/Search.vue index d2784ccce..3981483fc 100644 --- a/src/templates/Search.vue +++ b/src/templates/Search.vue @@ -30,7 +30,7 @@ query ($private: Int){ - projects: allProject (filter: { private: { ne: $private }, tags: { id: {in: ["farming"]}}}){ + projects: allProject (filter: { private: { ne: $private }, tags: { id: {in: ["tech", "foundation"]}}}){ edges { node { id diff --git a/src/templates/Tag.vue b/src/templates/Tag.vue index 687b5925c..b16d459fc 100644 --- a/src/templates/Tag.vue +++ b/src/templates/Tag.vue @@ -130,7 +130,7 @@ } } - allProjectTag(filter: { title: {in: ["farming"]}}){ + allProjectTag(filter: { title: {in: ["tech", "foundation"]}}){ edges{ node{ id