refactor(v2): remove unused metadata for pages (#1694)

* refactor(v2): remove unused metadata for pages

* changelog
This commit is contained in:
Endi 2019-07-23 23:23:21 +07:00 committed by GitHub
parent 1c59b5bc1c
commit 8b60e93bcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View file

@ -4,6 +4,7 @@
## 2.0.0-alpha.24
- Remove unused metadata for pages. This minimize number of http request & smaller bundle size.
- Upgrade dependencies of css-loader from 2.x to 3.x. Css modules localIdentName hash now only use the last 4 characters instead of 8.
- Fix broken markdown linking replacement for mdx files
- Fix potential security vulnerability because we're exposing the directory structure of the host machine. Instead of absolute path, we use relative path from site directory. Resulting in shorter webpack chunk naming and smaller bundle size.

View file

@ -8,7 +8,7 @@
const globby = require('globby');
const path = require('path');
const fs = require('fs');
const {encodePath, fileToPath, docuHash} = require('@docusaurus/utils');
const {encodePath, fileToPath} = require('@docusaurus/utils');
const DEFAULT_OPTIONS = {
path: 'src/pages', // Path to data on filesystem, relative to site dir.
@ -63,22 +63,15 @@ module.exports = function(context, opts) {
return;
}
const {addRoute, createData} = actions;
const {addRoute} = actions;
await Promise.all(
content.map(async metadataItem => {
const {permalink, source} = metadataItem;
const metadataPath = await createData(
`${docuHash(permalink)}.json`,
JSON.stringify(metadataItem, null, 2),
);
addRoute({
path: permalink,
component: source,
exact: true,
modules: {
metadata: metadataPath,
},
});
}),
);