Skip to content

NuxtJS plugin that creates a clean and elegant way to fetch data from DatoCMS.

License

Notifications You must be signed in to change notification settings

ajshortt/nuxt-datocms

Repository files navigation

Nuxt DatoCMS Plugin


⚠️ This module is currently in development: It is not ready for production use


npm version npm downloads License

NuxtJS plugin that creates a clean and elegant way to fetch data from DatoCMS.

📖 Release Notes

Setup

  1. Add @ajshortt/nuxt-datocms dependency to your project
yarn add @ajshortt/nuxt-datocms # or npm install @ajshortt/nuxt-datocms
  1. Add nuxt-datocms to the modules section of nuxt.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
    }
  }
}
  1. 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)
}

Documentation

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

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

Copyright (c) Alex Shortt [email protected]

About

NuxtJS plugin that creates a clean and elegant way to fetch data from DatoCMS.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published