Git Product home page Git Product logo

Comments (3)

danielroe avatar danielroe commented on June 13, 2024

Does your HCMS have a running Nuxt server currently?

from nuxt.

kevinhaeni avatar kevinhaeni commented on June 13, 2024

We have our nuxt project/code included in the HCMS and call it like programmatically like this:
(We also mock the nuxt/content module with a custom content wrapper to inject the to be previewed page-draft content into the inmemory lokidb (for that we will also need to find a replacement solution)

module.exports.renderPage = async (draftContent, livingdocsApis) => {
  let contentApi
  const projectId = draftContent.systemdata.projectId
  const { language, slug } = draftContent.metadata
  const route = `/${language.locale}/${slug}`

  const config = await loadNuxtConfig({
    rootDir: path.join(__dirname, '../'),
    for: 'start'
  })

  config.dev = false
  config._start = true
  config.router = { mode: 'hash' }
  config.modules = config.modules.filter(module => module !== '@nuxt/content')
  config.modules.push('~/modules/content/async.js')
  config.hooks = {
    content: {
      api (hook) {
        contentApi = hook
      }
    }
  }
  config.build.publicPath = '/proxy/api/_nuxt/'

  const nuxt = new Nuxt(config)
  await nuxt.ready() // it initialize `hooks` & `modules` from the `config` object

  contentApi.overrideLivingdocsService(projectId, livingdocsApis)
  await contentApi.insert(draftContent)

  const renderedRoute = await nuxt.renderRoute(route)
  await nuxt.close()

  return renderedRoute
}

Then we can get the generated HTML :
const {html, error} = await ssg.renderPage(doc, livingdocsApi)

from nuxt.

kevinhaeni avatar kevinhaeni commented on June 13, 2024

Any idea/updates/hint?

from nuxt.

Related Issues (20)

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.