stackpress
Version:
Incept is a content management framework.
40 lines (39 loc) • 1.37 kB
JavaScript
import path from 'node:path';
import * as reactus from 'reactus';
export default async function build(server) {
const cwd = server.config.path('server.cwd', process.cwd());
const plugins = server.config.path('view.engine.plugins', []);
const cssFiles = server.config.path('view.engine.cssFiles', []);
const assetPath = server.config.path('view.engine.assetPath', path.join(cwd, '.build/assets'));
const clientPath = server.config.path('view.engine.clientPath', path.join(cwd, '.build/client'));
const pagePath = server.config.path('view.engine.pagePath', path.join(cwd, '.build/pages'));
const engine = reactus.build({
cwd,
plugins,
assetPath,
clientPath,
pagePath,
cssFiles
});
for (const views of server.views.values()) {
for (const view of views) {
await engine.set(view.entry);
}
}
if (engine.size === 0) {
return [];
}
const responses = [
...await engine.buildAllClients(),
...await engine.buildAllAssets(),
...await engine.buildAllPages()
].map(response => {
const results = response.results;
if (typeof results?.contents === 'string') {
results.contents = results.contents.substring(0, 100) + ' ...';
}
return results;
});
return responses;
}
;