Last active
September 7, 2019 14:05
-
-
Save noxify/4663ce9b7bee433c125a2fc12150a043 to your computer and use it in GitHub Desktop.
test gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source https://gridsome.org/docs/taxonomies | |
api.loadSource(store => { | |
const posts = store.addContentType('Post') | |
const tags = store.addContentType('Tag') | |
// makes all ids in the `tags` field reference a `Tag` | |
posts.addReference('tags', 'Tag') | |
tags.addNode({ | |
id: '1', | |
title: 'The author' | |
}) | |
posts.addNode({ | |
id: '1', | |
title: 'A post', | |
tags: ['1'] | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source: https://gridsome.org/docs/taxonomies | |
query Tag($id: String!, $page: Int) { | |
tag(id: $id) { | |
title | |
belongsTo(page: $page) @paginate { | |
totalCount | |
pageInfo { | |
totalPages | |
currentPage | |
} | |
edges { | |
node { | |
... on Post { | |
id | |
title | |
path | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source: https://gridsome.org/docs/taxonomies | |
<template> | |
<Layout> | |
<h1>{{ $page.tag.title }}</h1> | |
<ul> | |
<li v-for="edge in $page.tag.belongsTo.edges" :key="edge.node.id"> | |
<g-link :to="edge.node.path"> | |
{{ edge.node.title }} | |
</g-link> | |
</li> | |
</ul> | |
</Layout> | |
</template> | |
<page-query> | |
query Tag($id: String!) { | |
tag(id: $id) { | |
title | |
belongsTo { | |
edges { | |
node { | |
... on Post { | |
id | |
title | |
path | |
} | |
} | |
} | |
} | |
} | |
} | |
</page-query> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment