mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-23 03:29:11 +02:00
refactor(v2): determine all available routes/url (#1264)
* refactor(v2): determine all available routes/url * nits * test(v2): routes snapshot * sort for consistent snapshot test due to async ordering
This commit is contained in:
parent
c73da00252
commit
2ad7413dd7
5 changed files with 114 additions and 41 deletions
|
@ -5,7 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const _ = require('lodash');
|
||||
const path = require('path');
|
||||
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
|
||||
const webpackNiceLog = require('webpack-nicelog');
|
||||
|
@ -22,25 +21,16 @@ module.exports = function createServerConfig(props) {
|
|||
// Workaround for Webpack 4 Bug (https://github.com/webpack/webpack/issues/6522)
|
||||
config.output.globalObject('this');
|
||||
|
||||
const {siteConfig, docsMetadatas, pagesMetadatas, contentsStore} = props;
|
||||
const {siteConfig, routesPaths} = props;
|
||||
|
||||
// Static site generator webpack plugin.
|
||||
const docsFlatMetadatas = Object.values(docsMetadatas);
|
||||
|
||||
// TODO: Generalize for blog plugin.
|
||||
const blogPermalinks = _.get(contentsStore, ['blog', 'contents'], []);
|
||||
const paths = [
|
||||
...blogPermalinks,
|
||||
...docsFlatMetadatas,
|
||||
...pagesMetadatas,
|
||||
].map(data => data.permalink);
|
||||
config.plugin('siteGenerator').use(StaticSiteGeneratorPlugin, [
|
||||
{
|
||||
entry: 'main',
|
||||
locals: {
|
||||
baseUrl: siteConfig.baseUrl,
|
||||
},
|
||||
paths,
|
||||
paths: routesPaths,
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue