⚠️ This module is currently in development: It is not ready for production use
NuxtJS plugin that creates a clean and elegant way to fetch data from DatoCMS.
- Add
@ajshortt/nuxt-datocms
dependency to your project
yarn add @ajshortt/nuxt-datocms # or npm install @ajshortt/nuxt-datocms
- Add
nuxt-datocms
to themodules
section ofnuxt.config.js
/// nuxt.config.js
{
modules: [
// Simple usage
['nuxt-datocms', {
options: {
datoToken: <DATO-API-TOKEN> // Add Dato API token
}
}]
]
}
Or a separate section nuxt-datocms
for module options:
// nuxt.config.js
{
modules: [
// Simple usage
'nuxt-datocms',
],
'nuxt-datocms': {
options: {
datoToken: <DATO-API-TOKEN> // Add Dato API token
}
}
}
- Test fetching data from DatoCMS within a page's
asyncData
lifecycle method.
async asyncData({ $cms }) {
const data = await $cms.records.fetchRaw(`query {
_site {
locales
}
}`)
console.log(data)
}
For all configuration, further setup and usage information, please do the following
Move to the docs
directory:
cd docs
Install dependencies and start the project in development mode:
yarn && yarn dev
- Clone this repository
- Install dependencies using
yarn install
ornpm install
- Start development server using
npm run dev
Copyright (c) Alex Shortt [email protected]