Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
added guard against hmr #42
Browse files Browse the repository at this point in the history
  • Loading branch information
alidcast committed Aug 8, 2017
1 parent 53d92b5 commit 818a703
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Vue from 'vue'
const { join } = require('path')

const options = <%= JSON.stringify(options) %>

const mdComps = {}

function importAllMdComps (r) {
Expand All @@ -30,9 +29,12 @@ Vue.component('nuxtent-body', {
}
})

export default ({ app, isClient, isServer }) => {
export default ({ app, isServer, isClient, hotReload }) => {
if (hotReload) return

const isAPI = isServer || !process.env.STATIC
const cache = {}
const isAPI = (options.isDev || isServer) && !process.env.STATIC

async function fetchContent (path, permalink, query = '') {
if (isAPI) {
const apiEndpoint = join(path, permalink + query)
Expand All @@ -45,7 +47,6 @@ export default ({ app, isClient, isServer }) => {
const serializedPermalink = permalink.replace(allButFirstSlash, '.')
const browserPath = join(path, serializedPermalink) + '.json'
if (!cache[browserPath]) {
// TODO catch errors
cache[browserPath] = (await app.$axios.get(browserPath)).data
}
return cache[browserPath]
Expand Down

0 comments on commit 818a703

Please sign in to comment.