Skip to content

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

Notifications You must be signed in to change notification settings

StudioRotate/nuxt-datocms

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nuxt DatoCMS Plugin

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

Setup

  1. Add nuxt-datocms module to your project
# Navigate to modules directory of Nuxt project
cd modules

# If modules doesn't exist, create it
mkdir modules && cd modules

# Clone this repo to modules directory
git clone https://github.com/StudioRotate/nuxt-datocms.git
  1. Add required module dependecies
yarn add datocms-listen graphql graphql-requeset
  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 read the parent Plugin Docs.

Development

This module is currently a forked and modified version of @ajshortt/nuxt-datocms. It is recommended that changes be made on an instance-by-instance manner. However, if the changes are very useful to other instances, please submit a PR within the module repo

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%