diff --git a/gridsome.config.js b/gridsome.config.js
index f9984a47a..f03eefd14 100644
--- a/gridsome.config.js
+++ b/gridsome.config.js
@@ -238,13 +238,19 @@ module.exports = {
tags: {
typeName: 'BlogTag',
create: true
+ },
+
+ category: {
+ typeName: 'BlogCategory',
+ create: true
}
+
}
}
},
{
- use: '@gridsome/source-filesystem',
+ use: '@gridsome/source-filesystem',
options: {
typeName: 'News',
path: './content/news/**/*.md',
@@ -253,6 +259,11 @@ module.exports = {
tags: {
typeName: 'NewsTag',
create: true
+ },
+
+ category: {
+ typeName: 'NewsCategory',
+ create: true
}
}
}
diff --git a/src/components/VerticalNav.vue b/src/components/VerticalNav.vue
index 4f841719d..250fe2293 100644
--- a/src/components/VerticalNav.vue
+++ b/src/components/VerticalNav.vue
@@ -5,10 +5,9 @@
v-for="(slide, index) in slides"
:key="index"
:href="`#${index}`"
- class="mt-1 capitalize group flex items-center px-3 py-2 text-sm leading-5 font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition ease-in-out duration-150"
+ class="mt-1 capitalize group flex items-center px-3 py-2 text-sm leading-5 font-medium hover:text-gray-900 hover:bg-gray-400 focus:outline-none transition border-blue-500 hover:bg-gray-100 transition ease-in-out duration-150"
:class="{
- 'text-gray-900 border-r-3 border-blue-500 hover:bg-gray-100':
- activeIndex === index,
+ 'border-r-3 border-blue-500 hover:bg-gray-100': activeIndex === index,
}"
@click="setActive(index)"
>
@@ -20,12 +19,14 @@
class="content inline-block h-full w-3/4 align-top p-5 transition ease-in-out duration-150"
>
-
![]()
-
+
@@ -45,5 +46,4 @@ export default {
},
},
};
-
-
+
\ No newline at end of file
diff --git a/src/components/custom/TagFilterHeader.vue b/src/components/custom/TagFilterHeader.vue
index d7e6d4008..5f9ae68d4 100644
--- a/src/components/custom/TagFilterHeader.vue
+++ b/src/components/custom/TagFilterHeader.vue
@@ -9,6 +9,11 @@
>filter:
+
+
@@ -105,6 +115,9 @@ export default {
this.open = false;
}
},
+ resetAll() {
+ this.$emit("resetAll", true);
+ },
},
mounted() {
document.addEventListener("click", this.close);
diff --git a/src/pages/Blog.vue b/src/pages/Blog.vue
index 4887c1a60..5b0c96544 100644
--- a/src/pages/Blog.vue
+++ b/src/pages/Blog.vue
@@ -1,6 +1,6 @@
-
-
+
@@ -21,23 +21,22 @@
/>
-
-
+
-query{
- entries: allBlog(sortBy: "created", order: DESC) {
+query($page: Int){
+ entries: allBlog(perPage: 10, page: $page, sortBy: "created", order: DESC, filter: {category: { id: {in: ["farming"]}}}) @paginate{
totalCount
pageInfo {
totalPages
@@ -52,6 +51,10 @@ query{
path
}
excerpt
+ category{
+ id
+ title
+ }
image(width:800)
path
humanTime : created(format:"DD MMM YYYY")
@@ -84,7 +87,7 @@ import NewsFilterHeader from "~/components/custom/NewsFilterHeader.vue";
export default {
data() {
const allMonths = [
- "All",
+ "All Months",
"January",
"February",
"March",
@@ -99,23 +102,23 @@ export default {
"December",
];
const currYear = new Date().getFullYear();
- var years = ["All"]
- var r = this.range(2019, currYear)
+ var years = ["All Years"];
+ var r = this.range(2019, currYear);
r.forEach((year) => years.push(String(year)));
- return {
- selectedTopic: "All",
- selectedYear: "All",
- selectedMonth: "All",
+ return {
+ selectedTopic: "All Topics",
+ selectedYear: "All Years",
+ selectedMonth: "All Months",
months: allMonths,
years: years,
listArchive: false,
- archiveButtonText : "Archive"
+ archiveButtonText: "Archive",
};
},
metaInfo: {
- title: "Newsroom",
+ title: "Blog",
},
components: {
PostListItem,
@@ -133,75 +136,68 @@ export default {
this.selectedMonth = month;
},
resetAll() {
- this.selectedTopic = "All";
- this.selectedYear = "All";
- this.selectedMonth = "All";
+ this.selectedTopic = "All Topics";
+ this.selectedYear = "All Years";
+ this.selectedMonth = "All Months";
},
range(start, end, step) {
- var range = [];
- var typeofStart = typeof start;
- var typeofEnd = typeof end;
+ var range = [];
+ var typeofStart = typeof start;
+ var typeofEnd = typeof end;
- if (step === 0) {
- throw TypeError("Step cannot be zero.");
+ if (step === 0) {
+ throw TypeError("Step cannot be zero.");
+ }
+
+ if (typeofStart == "undefined" || typeofEnd == "undefined") {
+ throw TypeError("Must pass start and end arguments.");
+ } else if (typeofStart != typeofEnd) {
+ throw TypeError("Start and end arguments must be of same type.");
+ }
+
+ typeof step == "undefined" && (step = 1);
+
+ if (end < start) {
+ step = -step;
+ }
+
+ if (typeofStart == "number") {
+ while (step > 0 ? end >= start : end <= start) {
+ range.push(start);
+ start += step;
+ }
+ } else if (typeofStart == "string") {
+ if (start.length != 1 || end.length != 1) {
+ throw TypeError("Only strings with one character are supported.");
}
- if (typeofStart == "undefined" || typeofEnd == "undefined") {
- throw TypeError("Must pass start and end arguments.");
- } else if (typeofStart != typeofEnd) {
- throw TypeError("Start and end arguments must be of same type.");
+ start = start.charCodeAt(0);
+ end = end.charCodeAt(0);
+
+ while (step > 0 ? end >= start : end <= start) {
+ range.push(String.fromCharCode(start));
+ start += step;
}
+ } else {
+ throw TypeError("Only string and number types are supported");
+ }
- typeof step == "undefined" && (step = 1);
-
- if (end < start) {
- step = -step;
- }
-
- if (typeofStart == "number") {
-
- while (step > 0 ? end >= start : end <= start) {
- range.push(start);
- start += step;
- }
-
- } else if (typeofStart == "string") {
-
- if (start.length != 1 || end.length != 1) {
- throw TypeError("Only strings with one character are supported.");
- }
-
- start = start.charCodeAt(0);
- end = end.charCodeAt(0);
-
- while (step > 0 ? end >= start : end <= start) {
- range.push(String.fromCharCode(start));
- start += step;
- }
-
- } else {
- throw TypeError("Only string and number types are supported");
- }
-
- return range;
-
- }
+ return range;
+ },
},
computed: {
-
topics: function () {
- var res = ["All"];
+ var res = ["All Topics"];
this.$page.topics.edges.forEach((edge) => res.push(edge.node.title));
return res;
- },
+ },
contentHeight() {
if (process.isClient) {
return window.innerHeight - 100;
}
},
-
- blogs() {
+ blogs() {
var res = {};
var old = this.$page.entries;
res.totalCount = old.totalCount;
@@ -210,27 +206,29 @@ export default {
for (var i = 0; i < old.edges.length; i++) {
var node = old.edges[i].node;
-
+
// Now check topic
- var topics = ["All"];
+ var topics = ["All Topics"];
node.tags.forEach((tag) => topics.push(tag.title));
-
+
var nodeDate = new Date(node.datetime);
if (!topics.includes(this.selectedTopic)) continue;
// Check year
- var years = ["All", String(nodeDate.getFullYear())];
-
+ var years = ["All Years", String(nodeDate.getFullYear())];
+
if (!years.includes(this.selectedYear)) continue;
-// Check Month
- var months = ["All", this.months[nodeDate.getMonth() + 1]];
+ // Check Month
+ var months = ["All Months", this.months[nodeDate.getMonth() + 1]];
if (!months.includes(this.selectedMonth)) continue;
res.edges.push({ node: node, id: node.id });
}
return res;
},
- },
-
+ baseurl() {
+ return "/blog/";
+ },
+ },
};
diff --git a/src/pages/News.vue b/src/pages/News.vue
index 78f300d82..b2769fc67 100644
--- a/src/pages/News.vue
+++ b/src/pages/News.vue
@@ -32,15 +32,15 @@
:currentPage="$page.entries.pageInfo.currentPage"
:totalPages="$page.entries.pageInfo.totalPages"
:maxVisibleButtons="5"
- v-if="$page.entries.pageInfo.totalPages > 1"
+ v-if="$page.entries.pageInfo.totalPages > 1 && news.edges.length > 0"
/>
-query{
- entries: allNews(sortBy: "created", order: DESC) {
+query($page: Int){
+ entries: allNews(perPage: 10, page: $page, sortBy: "created", order: DESC, filter: {category: { id: {in: ["farming"]}}}) @paginate{
totalCount
pageInfo {
totalPages
@@ -55,6 +55,10 @@ query{
path
}
excerpt
+ category{
+ id
+ title
+ }
image(width:800)
path
humanTime : created(format:"DD MMM YYYY")
@@ -82,7 +86,7 @@ import Pagination from "~/components/custom/Pagination.vue";
export default {
data() {
const allMonths = [
- "All",
+ "All Months",
"January",
"February",
"March",
@@ -97,14 +101,14 @@ export default {
"December",
];
const currYear = new Date().getFullYear();
- var years = ["All"];
+ var years = ["All Years"];
var r = this.range(2019, currYear);
r.forEach((year) => years.push(String(year)));
return {
- selectedTopic: "All",
- selectedYear: "All",
- selectedMonth: "All",
+ selectedTopic: "All Topics",
+ selectedYear: "All Years",
+ selectedMonth: "All Months",
months: allMonths,
years: years,
listArchive: false,
@@ -131,9 +135,9 @@ export default {
this.selectedMonth = month;
},
resetAll() {
- this.selectedTopic = "All";
- this.selectedYear = "All";
- this.selectedMonth = "All";
+ this.selectedTopic = "All Topics";
+ this.selectedYear = "All Years";
+ this.selectedMonth = "All Months";
},
toggleListArchive() {
if (this.listArchive) {
@@ -198,13 +202,13 @@ export default {
},
computed: {
topics: function () {
- var res = ["All"];
+ var res = ["All Topics"];
this.$page.topics.edges.forEach((edge) => res.push(edge.node.title));
return res;
},
baseurl: function () {
- return "";
+ return "/news/";
},
news() {
@@ -221,26 +225,26 @@ export default {
const diffDays = Math.ceil(diff / (1000 * 60 * 60 * 24));
var selected = false;
- if (!this.listArchive && diffDays <= 30) {
- selected = true;
- } else if (this.listArchive && diffDays > 30) {
- selected = true;
- }
+ // if (!this.listArchive && diffDays <= 180) {
+ // selected = true;
+ // } else if (this.listArchive && diffDays > 180) {
+ // selected = true;
+ // }
- if (!selected) continue;
+ // if (!selected) continue;
// Now check topic
- var topics = ["All"];
+ var topics = ["All Topics"];
node.tags.forEach((tag) => topics.push(tag.title));
if (!topics.includes(this.selectedTopic)) continue;
// Check year
- var years = ["All", String(nodeDate.getFullYear())];
+ var years = ["All Years", String(nodeDate.getFullYear())];
if (!years.includes(this.selectedYear)) continue;
// Check Month
- var months = ["All", this.months[nodeDate.getMonth() + 1]];
+ var months = ["All Months", this.months[nodeDate.getMonth() + 1]];
if (!months.includes(this.selectedMonth)) continue;
res.edges.push({ node: node, id: node.id });