3.0.10 • Published 3 years ago

nuxt-module-amit v3.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

contentstack-nuxt-module

Contentstack Nuxt Module is based on Contentstack javascript sdk along with additional functionality.

Features

  • Allow you to fetch content from multiple stacks
  • Make this.contentstack available globally

How to install contentstack-nuxt-module

npm i @nuxtjs/contentstack-module

Setup needed in nuxt.config.ts

Default setup without live preview

export default {
    modules: [
      contentstack
    ],
    contentstack:{
      stackConfig:[{
        name: 'Name for the stack',
        apiKey: 'stack_api_key',
        deliveryToken: 'stack_delivery_token',
        environment: 'publishing_environment',
        region: 'stack_region',
        customHost:'optional use only when custom region is required'
      }]
    }
}

Default Setup with Live Preview

export default {
    modules: [
      contentstack
    ],
    contentstack:{
      stackConfig:[{
        name: 'Name for the stack',
        apiKey: 'stack_api_key',
        deliveryToken: 'stack_delivery_token',
        environment: 'publishing_environment',
        region: 'stack_region',
        apiHost: 'api host api for live preview',
        appHost: 'app host for live edit',
        managementToken: 'management token with readonly accesses',
        livePreview: true,
        liveEdit: false,
        customHost:'optional use only when custom region is required'
      }]
    }
}

Multiple stack support

export default {
    modules: [
      contentstack
    ],
    contentstack:{
      stackConfig:[{
        name: 'Name for the stack',
        apiKey: 'stack_api_key',
        deliveryToken: 'stack_delivery_token',
        environment: 'publishing_environment',
        region: 'stack_region',
        apiHost: 'api host api for live preview',
        appHost: 'app host for live edit',
        managementToken: 'management token with readonly accesses',
        livePreview: true,
        liveEdit: false,
        customHost:'optional use only when custom region is required'
      },{
        name: 'Name for the stack',
        apiKey: 'stack_api_key',
        deliveryToken: 'stack_delivery_token',
        environment: 'publishing_environment',
        region: 'stack_region',
        customHost:'optional use only when custom region is required'
      }]
    }
}

NOTE: If stackName field contains spaces special characters for example Starter/app expected output would be StarterApp. If no value is added in stackName field expected output would be Stack1.

NOTE: If you want to custom region stack with can add them using customHost example customHost:'cdn.contentstack.io'

NOTE: Live preview can only be applicable to one stack instance at a time.

Usage

Add the following script to your .vue file and use it in your template.

<script setup>
const { $contentstack } = useNuxtApp()
await $contentstack?.NameForStack.stack.ContentType('contentTypeUID').Query().toJSON().find()
</script>

Docs to reference

3.0.10

3 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago