Code Monkey home page Code Monkey logo

nuxt-ghost-starter's Introduction

nuxt-ghost-starter

Nuxt Static and Universal site generation using the Ghost Content API and NUXTJS

Site fetches and provides Ghost blog data to NUXTJS components With data already provided to the VUE components, a site can be rapidly templated

Build Setup

To get the Ghost Content API working, you will first need to access your blog's backend to get the API key. Instructions may be found here.

You will then need to provide this information to the file .env.example, and the rename this file to '.env'. This app uses @nuxtjs/dotenv to load these environment variables into the project.

# install dependencies
$ npm install

# serve with hot reload at localhost:3000
$ npm run dev

# build for production and launch server
$ npm run build
$ npm start

# generate static project
$ npm run generate

Important Configuration

The /util/ghost.js file contains some important configuration items.

First, it exports the GhostContent API that can then be used in components to fetch data (for both static and universal site generation). This must be called as a function in other components.

Second, you will see the array postIndexFields. As you may not want to provide all post data to you home page for posts links, you can configure desired items in this array. See the Ghost Content API for more details.

Last but not least, it contains a function called generateRoutes that is imported in nuxt.config.js. This will generate dynamic routes (depending on how many post pages, authors, and tags are fetched) when you run npm run generate. See Nuxt generate property.

You may need to tweak this to your liking, but for now it generates are post, pages, and index pages for all posts, posts by tag, and post by author with pagination.

In nuxt.config.js you will also note that:

generate: {
    subFolders: false,
    ...
  }

The subFolders property was set to false to be able to provide a 404 error pages with Ghost's Navigation data (dynamic data retrieved from Ghost) when generating a static site. This page is 404.vue.

In Action

To see a Netlify-hosted, statically generated version of this site in action, visit https://blog.jacobgoodwin.me

For a detailed explanation on how things work, checkout Nuxt.js docs.

nuxt-ghost-starter's People

Contributors

jacobsngoodwin avatar mcnaveen avatar stevemayne 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.