使用bolt cms用于单页面应用程序

时间:2017-11-11 16:50:30

标签: bolt-cms

我想用螺栓作为无头cms。我的计划是创建一个基于vue.js的模板,并使用bolt插件jsonAPI加载内容。 但我正在努力与主题和配置设置。 我想禁用CMS中的所有路由,并仅返回带有css和js文件的静态html。

2 个答案:

答案 0 :(得分:3)

I think your problem could be solved by the following alternative solution :

Use different domain

Put your vue SPA app in yourdomain.com and put your bolt as RESTAPI provider in subdomain.yourdomain.com. Since it's a subdomain, you would not face any CORST problem, and you can follow common tutorial how to setup bolt cms and how to build vuejs SPA.


Use vuejs SPA in bolt cms template

Assume you develop vuejs SPA using webpack, you have to setup asset public path as bolt template location, the configuration file is in your-vue-directory/config/index.js

module.exports = {
  build: {
    assetsPublicPath: '/theme/your-theme/',
    ......
  },
}

Then after finish build the app, you can copy your build files from your-vue-directory/dist into your-bolt-directory/public/theme/your-theme

But using this solution, if you're using vue-router, i think you cannot use 'history'mode since all of the routing will be handled by bolt cms. The only possible router-mode is 'hash'.

答案 1 :(得分:1)

最简单的方法是让他们都使用相同的模板,让模板说<html></html>,然后就完成了。