nuxt-microcms-module
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.1 • Public • Published

    ⚠️ Nuxt3 is not supported. Please use Nuxt2.

    nuxt-microcms-module

    microCMS integration for Nuxt.

    Getting Started

    Install

    $ npm install nuxt-microcms-module

    Setup

    // nuxt.config.js
    
    export default {
      modules: ['nuxt-microcms-module'],
      microcms: {
        options: {
          serviceDomain: "YOUR_DOMAIN", // YOUR_DOMAIN is the XXXX part of XXXX.microcms.io
          apiKey: "YOUR_API_KEY",
        },
        mode: process.env.NODE_ENV === 'production' ? 'server' : 'all',
      },
    };

    options.serviceDomain

    String
    Your service id, which is a subdomain of microCMS.

    options.apiKey

    String
    Your api-key.
    It can be obtained from the service settings.

    mode

    String (can be client or server or all)
    If defined, this module will be included only on the respective (client or server) side.

    Hot to use

    This package uses microcms-js-sdk.
    You can get microCMS client ($microcms) from context.
    Please see the URL below for details.
    https://github.com/microcmsio/microcms-js-sdk#how-to-use

    // pages/index.vue
    
    <template>
      <ul>
        <li v-for="content in contents" :key="content.id">
          <nuxt-link :to="`/${content.id}`">
            {{ content.title }}
          </nuxt-link>
        </li>
      </ul>
    </template>
    
    <script>
    export default {
      async asyncData({ $microcms }) {
        const data = await $microcms.get({
          endpoint: 'your_endpoint',
          queries: { limit: 20, filters: 'createdAt[greater_than]2021' },
        });
        return data;
      }
    }
    </script>

    LICENSE

    Apache-2.0

    Install

    npm i nuxt-microcms-module

    DownloadsWeekly Downloads

    327

    Version

    2.0.1

    License

    Apache-2.0

    Unpacked Size

    18 kB

    Total Files

    15

    Last publish

    Collaborators

    • himaratsu
    • shibe97
    • hiro08