mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
commit
a6b99cc6a9
@ -340,6 +340,10 @@ It works exactly as before. You need to add `strapi-views` into your app's depen
|
||||
```json
|
||||
{
|
||||
"views": {
|
||||
"enabled": true,
|
||||
"map": {
|
||||
"ejs": "ejs"
|
||||
},
|
||||
"viewExt": "ejs",
|
||||
"debug": true,
|
||||
"cache": true
|
||||
|
||||
@ -10,6 +10,7 @@ const path = require('path');
|
||||
// Public node modules.
|
||||
const _ = require('lodash');
|
||||
const consolidate = require('consolidate');
|
||||
const views = require('koa-views');
|
||||
|
||||
/**
|
||||
* Public assets hook
|
||||
@ -69,7 +70,7 @@ module.exports = strapi => {
|
||||
});
|
||||
|
||||
strapi.app.use(
|
||||
strapi.koaMiddlewares.views(
|
||||
views(
|
||||
path.resolve(strapi.config.appPath, strapi.config.paths.views),
|
||||
opts
|
||||
)
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "strapi-views",
|
||||
"name": "strapi-middleware-views",
|
||||
"version": "3.0.0-alpha.6.3",
|
||||
"description": "Views hook to enable server-side rendering for the Strapi framework",
|
||||
"homepage": "http://strapi.io",
|
||||
@ -16,6 +16,7 @@
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"consolidate": "^0.14.5",
|
||||
"koa-views": "^6.1.1",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
"strapi": {
|
||||
@ -45,4 +46,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,8 @@ module.exports = function() {
|
||||
'./node_modules/strapi-utils',
|
||||
'./node_modules/strapi-generate*',
|
||||
'./node_modules/strapi-plugin-*',
|
||||
'./node_modules/strapi-helper-*'
|
||||
'./node_modules/strapi-helper-*',
|
||||
'./node_modules/strapi-middleware-*'
|
||||
]
|
||||
}, (err, files) => {
|
||||
if (err) {
|
||||
|
||||
@ -46,6 +46,23 @@ module.exports = function() {
|
||||
}
|
||||
);
|
||||
}),
|
||||
new Promise((resolve, reject) => {
|
||||
const cwd = process.cwd();
|
||||
|
||||
glob(
|
||||
'./node_modules/*(strapi-middleware-*)',
|
||||
{
|
||||
cwd
|
||||
},
|
||||
(err, files) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
mountMiddlewares.call(this, files, cwd)(resolve, reject);
|
||||
}
|
||||
);
|
||||
}),
|
||||
new Promise((resolve, reject) => {
|
||||
const cwd = path.resolve(__dirname, '..', 'middlewares');
|
||||
|
||||
@ -124,7 +141,8 @@ const mountMiddlewares = function (files, cwd) {
|
||||
return (resolve, reject) =>
|
||||
parallel(
|
||||
files.map(p => cb => {
|
||||
const name = p.split('/')[1];
|
||||
const name = p.replace(/^.\/node_modules\/strapi-middleware-/, './')
|
||||
.split('/')[1];
|
||||
|
||||
this.middleware[name] = {
|
||||
loaded: false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user