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

eclectic-coding avatar jacobsngoodwin avatar mcnaveen avatar stevemayne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nuxt-ghost-starter's Issues

Update ESLint/Prettier

Use recommended nuxt eslint configuration with prettier from most recent create-nuxt-app

Settings not passed to navigation component

@Maxbrain0 Good work! I now get the following error on each page (when running generate), which may or may not be related to the former problem:


 ERROR   /                                                                                                                                                                           19:50:44

TypeError: Cannot read property 'logo' of null
    at a.tt.components.Navigation (webpack/bootstrap:2:0)
    at a.t._render (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue/dist/vue.runtime.common.prod.js:6:35273)
    at /Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:70663
    at Yi (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:67227)
    at io (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:70639)
    at ro (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:70270)
    at _t.eo [as renderNode] (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:67517)
    at _t.next (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:20536)
    at n (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:18748)
    at /Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:68628
    at eo (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:68636)
    at /Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:70737
    at Yi (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:67227)
    at io (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:70639)
    at ro (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:70270)
    at _t.eo [as renderNode] (/Users/steve/git/fh/nuxt-ghost-starter/node_modules/vue-server-renderer/build.prod.js:1:67517)

It looks like settings isn't being passed into the Navigation component

Originally posted by @stevemayne in #10 (comment)

Exclude 404 error page from sitemap indexing

Hi,

Today I noticed while generating a sitemap via @nuxtjs/sitemap Module it include the dynamically generated 404 error page (pages/404.vue)
I used the module exclude option it does not exclude the 404 error page from the sitemap

Fetchevent Network Error Response

Just open URL first time I just check browser log without refresh that time I spotted the yellow warning message if refresh the page it's gone
sometimes this warning show even the page refresh

Screenshot from 2019-10-16 23-28-57

npm run generate no longer works

All pages that npm run generate attempts to create throw the following exception:

 ERROR   /the-editor                                                           13:54:36

TypeError: e is not a function
    at Store.nuxtServerInit (webpack/bootstrap:2:0)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

to replicate:

git clone x
npm install
npm run generate

TypeError: Cannot read property 'twitter' of null

TypeError: Cannot read property 'twitter' of null

npm run generate

Got this Error While generating a Static Page For Pages
Post are generated to HTML Pages Successfully

also got the anthor warning

ERROR  (node:5670) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead 

Asset updates

Get asset configuration working and css nano

Also get icon minification as mdi/icons are large and don't tree shake

Package express question.

Started experimenting with your starter. Great work.

My question is it seems you have express in package.json but it doesn't appeared to be used. Are we using a backend at all? If not we could probably safely remove. If this is the cases, nodemon could be removed as well.

I would be glad to make a PR if this is correct.

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.