Skip to content

🏷 Nuxt plugin adding support for automatic handling of taxonomies with Nuxt Content.

License

Notifications You must be signed in to change notification settings

thombruce/nuxt-taxonomies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nuxt Taxonomies

Become a Patron

GitHub issues

License

Plugin adding support for automatic handling of taxonomies with Nuxt Content.

Installation

# With Yarn
yarn add @thombruce/nuxt-taxonomies
# With npm
npm install @thombruce/nuxt-taxonomies --save

Add @thombruce/nuxt-taxonomies to buildModules in nuxt.config.js:

  buildModules: [
    // ...
    "@thombruce/nuxt-taxonomies",
    // ...
  ],

Usage

<script>
export default {
  async asyncData ({ $taxonomies }) {
    // To list all tags found in /content/blog files
    const tags = $taxonomies('tags', 'blog').all() // [{ slug: 'my-tag', title: 'My Tag' }, { slug: 'my-other-tag', title: 'My Other Tag' }]

    return { tags }
  }
}
<script>
export default {
  async asyncData ({ $taxonomies }) {
    // To retrieve a specific term
    const term = $taxonomies('tags', 'blog').find('my-tag') // { slug: 'my-tag', title: 'My Tag' }

    return { term }
  }
}
</script>

About

🏷 Nuxt plugin adding support for automatic handling of taxonomies with Nuxt Content.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published