Seamlessly use content files in your Nuxt.js sites.
Nuxtent is a tool designed to make using Nuxt for content-heavy sites as easy as using static site generators like Jekyll or Hugo. It achieves this by compiling data from markdown or YAML files based on configured rules and providing helpers for dynamically accessing this data within Nuxt pages. In addition, Nuxtent offers support for content files in both static sites and dynamic applications, the usage of Vue components inside markdown files, and automatic content navigation between pages and within pages.
npm install nuxtent
module.exports = {
// ...
markdownit: {
preset: 'default',
linkify: true,
breaks: true,
injected: true,
use: [
// Add any markdown-it plugins you want to use
]
},
// ...
}
module.exports = {
// ...
modules: [
'nuxtent'
],
// ...
}
Create a folder named “content” in your Nuxt project’s root directory. Inside this folder, create your markdown or YAML content files.
Access your markdown content and metadata within Nuxt pages by using the $content helper inside the asyncData method. Here’s an example:
export default {
asyncData({ app }) {
const myContent = app.$content('path/to/my/file').fetch()
return {
myContent
}
}
}
Nuxtent is a powerful tool that simplifies building content-heavy sites with Nuxt. Its features include simple configuration, support for different content structures, meta info and breadcrumbs, Vue component integration, and easy access to content and metadata within Nuxt pages. By providing these features, Nuxtent enhances the capabilities of Nuxt as a static site generator and offers a flexible API for configuring and fetching content.