mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
feat: use ejs to build html template
This commit is contained in:
parent
f07e7791fa
commit
d33343b7c6
6 changed files with 52 additions and 288 deletions
|
@ -1,4 +1,6 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const ejs = require('ejs');
|
||||
const staticSiteGenerator = require('static-site-generator-webpack-plugin');
|
||||
const webpackNiceLog = require('webpack-nicelog');
|
||||
const createBaseConfig = require('./base');
|
||||
|
@ -14,15 +16,21 @@ module.exports = function createProdConfig(props) {
|
|||
|
||||
const {siteConfig, docsData, pagesData} = props;
|
||||
|
||||
// Find all available paths to be rendered
|
||||
// static site generator webpack plugin
|
||||
const paths = [...docsData, ...pagesData].map(data => data.path);
|
||||
const template = ejs.compile(
|
||||
fs.readFileSync(
|
||||
path.resolve(__dirname, '../core/prodTemplate.ejs'),
|
||||
'utf-8'
|
||||
)
|
||||
);
|
||||
config.plugin('siteGenerator').use(staticSiteGenerator, [
|
||||
{
|
||||
entry: 'main',
|
||||
locals: {
|
||||
bundlejs: 'bundle.js',
|
||||
title: siteConfig.title || 'Munseo',
|
||||
lang: 'en'
|
||||
baseUrl: siteConfig.baseUrl,
|
||||
template
|
||||
},
|
||||
paths
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue