使用 KeystoneJS 作为博客,但只是 webapp 的一部分
Use KeystoneJS as a blog, but only part of the webapp
我有一个 NodeJS + Angular + MySQL webapp。有什么方法可以让我仅将 KeystoneJS 用于博客?
我目前将一些页面作为静态 Express 页面提供,另一些作为 Angular 应用程序提供,启用了 UI 路由器的 HTML5 模式。
// Serves static pages generated by Express
app.use('/staticPage', staticPage);
app.use('/anotherStaticPage', anotherStaticPage);
// Serves Angular App
app.all('/*', function(req, res, next) {
res.sendFile(__dirname + '/ui/index.html');
});
/*
Need a way to also serve a blog powered by KeystonJS
It should be accessed at /blog/:postTitle
*/
如果可能的话,我更愿意保留我现有的设置并简单地在其上添加 Keystone。
有两种方法可以做到这一点。
(1) 安装keystone,在keystones index router里面,添加你的两个静态路由器和一个app router。
(2) Add keystone to existing Express App.
但是不管 keystoneJS。您必须删除 angularApp 的通用处理程序。
app.all('/app/*', function(req, res, next) {...});
否则必须在 Angular 上方添加新的博客相关路由器,正如您目前所做的那样。
我有一个 NodeJS + Angular + MySQL webapp。有什么方法可以让我仅将 KeystoneJS 用于博客?
我目前将一些页面作为静态 Express 页面提供,另一些作为 Angular 应用程序提供,启用了 UI 路由器的 HTML5 模式。
// Serves static pages generated by Express
app.use('/staticPage', staticPage);
app.use('/anotherStaticPage', anotherStaticPage);
// Serves Angular App
app.all('/*', function(req, res, next) {
res.sendFile(__dirname + '/ui/index.html');
});
/*
Need a way to also serve a blog powered by KeystonJS
It should be accessed at /blog/:postTitle
*/
如果可能的话,我更愿意保留我现有的设置并简单地在其上添加 Keystone。
有两种方法可以做到这一点。
(1) 安装keystone,在keystones index router里面,添加你的两个静态路由器和一个app router。
(2) Add keystone to existing Express App.
但是不管 keystoneJS。您必须删除 angularApp 的通用处理程序。
app.all('/app/*', function(req, res, next) {...});
否则必须在 Angular 上方添加新的博客相关路由器,正如您目前所做的那样。