Git Product home page Git Product logo

cloudcms-nuxt's Introduction

Cloud CMS Nuxt Module

This module makes it easy to use Cloud CMS from within your Nuxt JS pages and components.

It provides the following:

  1. An initialized connect to Cloud CMS for use in query, search and retrieval of content.
  2. Optional support for Preview Mode (providing your editors with instant preview of editorial changes from within Cloud CMS).
  3. Optional support for Page Renditions (allowing your editors to see and preview precisely where a piece of content appears on the site).

You can find an example of a static site generated using Nuxt JS and Cloud CMS here: https://github.com/gitana/sdk/tree/master/nuxtjs/sample

This site uses the Cloud CMS Nuxt Module to deliver a working example of the aforementioned capabilities.

Installation

npm install -S cloudcms-nuxt

Nuxt

Add the module to your Nuxt configuration. You must include the contents of your gitana.json file, like this:

var config = require("./gitana.json");
module.exports = {
    ...,
    "modules": [
        ["cloudcms-nuxt", config]
    ]
}

You can also add the following optional configuration settings:

{
    ...,
    "preview": false,
    "renditions": false,
    "basePageUrl": "http://localhost:3000"
}

In more detail, these are:

  • preview - set to true to enable instant preview and branch switching capabilities
  • renditions - set to true to track generated page renditions (per content item) and make that information available to editors for preview selection
  • basePageUrl - set to the base URL of the server for instant preview

Example Usage

The $cloudcms context variable is available on the context, providing access to all functions in the Cloudcms driver. The $branch provides functions to your current project branch, which is by default master. Here is how you can read a node.

async asyncData(context) {
    let node = await context.$branch.readNode("myNodeId");
    // more awesome content functions
}

If you've enabled preview mode (i.e. preview set to true via config), then your web pages support the following additional request parameters:

?preview&branch={branchId}

Which allows you to request server-side rendering of the given page on top of the given Cloud CMS branch. This provides your editors (working in different branches) with the ability to preview their content without any server redeployments or restarts.

If you've enabled rendition tracking (i.e. trackRenditions set to true via config), then the nuxt generate build for the static site will automatically discover any content node IDs for every page generated. That information will be shipped back to the Cloud CMS API so that your editorial users can take advantage of it while editing and previewing their changes.

To tag pages as having generated using a specific node, just append the data-cms-id attribute into your DOM. For example,

<div class="item item-author-block author" :data-cms-id="author._doc">
    <a :href="authorLink">
        <div class="author-dp">
            <img v-bind:src="author.defaultAttachmentUrl" v-bind:alt="author.title">
        </div>
    </a>
</div>

cloudcms-nuxt's People

Contributors

cloudcms avatar mibewh avatar mteasdale1 avatar uzquiano avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.