fix tags
This commit is contained in:
@@ -176,7 +176,7 @@ module.exports = {
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
ProjectTag: [{
|
ProjectTag: [{
|
||||||
path: '/tags/:id',
|
path: '/projects/tags/:id',
|
||||||
component: '~/templates/Tag.vue'
|
component: '~/templates/Tag.vue'
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
|||||||
@@ -212,4 +212,38 @@ module.exports = function(api) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api.createPages(async({
|
||||||
|
graphql,
|
||||||
|
createPage
|
||||||
|
}) => {
|
||||||
|
// Use the Pages API here: https://gridsome.org/docs/pages-api
|
||||||
|
const {
|
||||||
|
data
|
||||||
|
} = await graphql(`{
|
||||||
|
allNewsTag {
|
||||||
|
edges {
|
||||||
|
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
|
||||||
|
data.allNewsTag.edges.forEach(function(element) {
|
||||||
|
createPage({
|
||||||
|
path: element.node.path,
|
||||||
|
component: './src/templates/Tag.vue',
|
||||||
|
context: {
|
||||||
|
id: element.node.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,11 @@
|
|||||||
<Layout :hideHeader="true" :disableScroll="true">
|
<Layout :hideHeader="true" :disableScroll="true">
|
||||||
<div class="container sm:pxi-0 mx-auto overflow-x-hidden pt-24">
|
<div class="container sm:pxi-0 mx-auto overflow-x-hidden pt-24">
|
||||||
<div class="mx-4 sm:mx-0">
|
<div class="mx-4 sm:mx-0">
|
||||||
<h1 class="pb-0 mb-0 text-5xl font-medium">{{ $page.projectTag.title }}</h1>
|
<h1 class="pb-0 mb-0 text-5xl font-medium">{{ tags.title }}</h1>
|
||||||
<p class="text-gray-700 text-xl">
|
<p class="text-gray-700 text-xl">
|
||||||
A
|
|
||||||
<span
|
<span
|
||||||
class="self-center"
|
class="self-center"
|
||||||
>{{ $page.projectTag.belongsTo.totalCount }} Projects</span>
|
>{{ tags.belongsTo.totalCount }} {{item}}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@
|
|||||||
|
|
||||||
<div class="flex flex-wrap pt-8 pb-8 mx-4 sm:-mx-4">
|
<div class="flex flex-wrap pt-8 pb-8 mx-4 sm:-mx-4">
|
||||||
<PostListItem
|
<PostListItem
|
||||||
v-for="edge in $page.projectTag.belongsTo.edges"
|
v-for="edge in tags.belongsTo.edges"
|
||||||
:key="edge.node.id"
|
:key="edge.node.id"
|
||||||
:record="edge.node"
|
:record="edge.node"
|
||||||
/>
|
/>
|
||||||
@@ -23,11 +22,11 @@
|
|||||||
|
|
||||||
<div class="pagination flex justify-center mb-8">
|
<div class="pagination flex justify-center mb-8">
|
||||||
<Pagination
|
<Pagination
|
||||||
:baseUrl="$page.projectTag.path"
|
:baseUrl="tags.path"
|
||||||
:currentPage="$page.projectTag.belongsTo.pageInfo.currentPage"
|
:currentPage="tags.belongsTo.pageInfo.currentPage"
|
||||||
:totalPages="$page.projectTag.belongsTo.pageInfo.totalPages"
|
:totalPages="tags.belongsTo.pageInfo.totalPages"
|
||||||
:maxVisibleButtons="5"
|
:maxVisibleButtons="5"
|
||||||
v-if="$page.projectTag.belongsTo.pageInfo.totalPages > 1"
|
v-if="tags.belongsTo.pageInfo.totalPages > 1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -70,11 +69,52 @@
|
|||||||
humanTime : startdate(format:"DD MMM YYYY")
|
humanTime : startdate(format:"DD MMM YYYY")
|
||||||
datetime : created
|
datetime : created
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newsTag(id: $id) {
|
||||||
|
title
|
||||||
|
path
|
||||||
|
belongsTo{
|
||||||
|
totalCount
|
||||||
|
pageInfo {
|
||||||
|
totalPages
|
||||||
|
currentPage
|
||||||
|
}
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
... on News {
|
||||||
|
title
|
||||||
|
excerpt
|
||||||
|
image(width:800)
|
||||||
|
path
|
||||||
|
timeToRead
|
||||||
|
humanTime : created(format:"DD MMM YYYY")
|
||||||
|
datetime : created
|
||||||
|
author {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
image(width:64, height:64, fit:inside)
|
||||||
|
path
|
||||||
|
}
|
||||||
|
},
|
||||||
|
... on Project {
|
||||||
|
title
|
||||||
|
excerpt
|
||||||
|
image(width:800)
|
||||||
|
path
|
||||||
|
humanTime : startdate(format:"DD MMM YYYY")
|
||||||
|
datetime : created
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</page-query>
|
</page-query>
|
||||||
|
|
||||||
@@ -87,10 +127,21 @@ export default {
|
|||||||
Pagination,
|
Pagination,
|
||||||
PostListItem
|
PostListItem
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed:{
|
||||||
|
tags(){
|
||||||
|
return this.$page.projectTag || this.$page.newsTag
|
||||||
|
},
|
||||||
|
item(){
|
||||||
|
var plural = this.tags.belongsTo.totalCount > 0
|
||||||
|
return this.$page.projectTag? plural? "projects" : "project" : "news"
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
metaInfo() {
|
metaInfo() {
|
||||||
return {
|
return {
|
||||||
title: ""
|
title: this.tags.title
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user