Add filter

This commit is contained in:
samaradel
2021-02-22 12:06:33 +02:00
parent d1b3744acf
commit 7350ccdb89
8 changed files with 97 additions and 94 deletions

View File

@@ -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
}
})
});
}

View File

@@ -36,7 +36,7 @@
<page-query>
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

View File

@@ -40,7 +40,7 @@
<page-query>
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

View File

@@ -16,7 +16,7 @@
<page-query>
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)
}
};
</script>

View File

@@ -136,7 +136,7 @@
}
}
tags: allProjectTag (filter: { title: {in: ["farming"]}}) {
tags: allProjectTag (filter: { title: {in: ["tech", "foundation"]}}) {
edges{
node{
id

View File

@@ -18,7 +18,7 @@
<page-query>
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 {

View File

@@ -30,7 +30,7 @@
<page-query>
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

View File

@@ -130,7 +130,7 @@
}
}
allProjectTag(filter: { title: {in: ["farming"]}}){
allProjectTag(filter: { title: {in: ["tech", "foundation"]}}){
edges{
node{
id