dynamic filteration based on env variables

This commit is contained in:
hamdy
2020-11-19 18:43:07 +02:00
parent a602b24db3
commit 193cec9fd8
7 changed files with 49 additions and 11 deletions

View File

@@ -34,6 +34,7 @@ query{
edges {
node {
title
excerpt
image(width:800)
path
humanTime : created(format:"DD MMM YYYY")

View File

@@ -1,60 +0,0 @@
<template>
<Layout>
<div class="container sm:pxi-0 mx-auto overflow-x-hidden">
<div class="flex flex-wrap with-large pt-8 pb-8 mx-4 sm:-mx-4">
<PostListItem v-for="edge in $page.entries.edges" :key="edge.node.id" :record="edge.node" />
</div>
</div>
</Layout>
</template>
<page-query>
query {
entries: allPerson (sortBy: "rank", order: DESC){
totalCount
edges {
node {
path
excerpt
content
name
rank
memberships{
id
title
path
}
bio
linkedin
websites
countries
cities
image(width:800)
private
}
}
}
}
</page-query>
<script>
import Pagination from "~/components/Pagination.vue";
import PostListItem from '~/components/PostListItem.vue';
export default {
metaInfo: {
title: "People"
},
components: {
PostListItem,
Pagination
},
computed: {
baseurl: function() {
return "/people/"
}
},
};
</script>

View File

@@ -1,67 +0,0 @@
<template>
<Layout>
<div class="container sm:pxi-0 mx-auto overflow-x-hidden">
<div class="flex flex-wrap with-large pt-8 pb-8 mx-4 sm:-mx-4">
<PostListItem v-for="edge in $page.entries.edges" :key="edge.node.id" :record="edge.node" />
</div>
</div>
</Layout>
</template>
<page-query>
query {
entries: allProject (sortBy: "rank", order: DESC){
totalCount
edges {
node {
title
path
members {
id
name
image(width:64, height:64, fit:inside)
path
},
tags {
id
title
path
}
rank
linkedin
startDate : startdate(format:"MM YYYY")
humanTime : created(format:"DD MMMM YYYY")
datetime : created(format:"ddd MMM DD YYYY hh:mm:ss zZ")
status
excerpt
image(width:800)
path
timeToRead
}
}
}
}
</page-query>
<script>
import PostListItem from '~/components/PostListItem.vue';
import Pagination from "~/components/Pagination.vue";
export default {
metaInfo: {
title: "Projects"
},
components: {
PostListItem,
Pagination
},
computed: {
baseurl: function() {
return "/projects/"
}
},
};
</script>

View File

@@ -1,158 +0,0 @@
<template>
<Layout>
<div class="container sm:pxi-0 mx-auto overflow-x-hidden my-auto">
<div
v-if="searchResults.length > 0"
class="flex flex-wrap with-large pt-8 pb-8 mx-4 sm:-mx-4"
>
<PostListItem
v-for="edge in searchResults"
:key="edge.node.id"
:record="edge.node"
/>
</div>
<div v-else class="flex flex-col with-large my-auto text-center">
<h1>404</h1>
<p>OOPS! Something went wrong here</p>
</div>
</div>
</Layout>
</template>
<page-query>
query {
projects: allProject {
edges {
node {
id
title
path
members {
id
name
image(width:64, height:64, fit:inside)
path
}
rank
linkedin
startDate : startdate(format:"MM YYYY")
humanTime : created(format:"DD MMMM YYYY")
datetime : created(format:"ddd MMM DD YYYY hh:mm:ss zZ")
status
excerpt
image(width:800)
path
timeToRead
author {
id
image(width:64, height:64, fit:inside)
path
}
}
}
}
people: allPerson {
edges {
node {
id
path
excerpt
content
name
rank
memberships{
id
title
path
}
bio
linkedin
websites
countries
cities
image(width:800)
private
}
}
}
blogs: allBlog {
edges {
node {
id
title
image(width:800)
path
humanTime : created(format:"DD MMM YYYY")
datetime : created
author {
id
name
image(width:64, height:64, fit:inside)
path
}
}
}
}
}
</page-query>
<script>
import PostListItem from "~/components/PostListItem.vue";
import Pagination from "~/components/Pagination.vue";
export default {
metaInfo: {
title: "Search",
},
data: () => ({
q: "",
objects: {},
}),
computed: {
searchResults() {
const searchTerm = this.q;
if (searchTerm.length < 3) return [];
var searchRes = this.$search.search({ query: searchTerm, limit: 5 });
var result = [];
for (var i = 0; i < searchRes.length; i++) {
var item = searchRes[i];
result.push({ node: this.objects[item.path] });
}
return result;
},
},
mounted() {
this.q = new URL(location.href).searchParams.get("query");
for (var i = 0; i < this.$page.projects.edges.length; i++) {
var item = this.$page.projects.edges[i];
this.objects[item.node.path] = item.node;
}
for (var i = 0; i < this.$page.people.edges.length; i++) {
var item = this.$page.people.edges[i];
this.objects[item.node.path] = item.node;
}
for (var i = 0; i < this.$page.blogs.edges.length; i++) {
var item = this.$page.blogs.edges[i];
this.objects[item.node.path] = item.node;
}
},
components: {
PostListItem,
Pagination,
},
};
</script>
<style scoped>
h1 {
font-size: 13rem;;
}
</style>