Skip to content

Instantly share code, notes, and snippets.

@noxify
Last active September 7, 2019 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noxify/4663ce9b7bee433c125a2fc12150a043 to your computer and use it in GitHub Desktop.
Save noxify/4663ce9b7bee433c125a2fc12150a043 to your computer and use it in GitHub Desktop.
test gist
//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']
})
}
//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
}
}
}
}
}
}
//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