From 8b60e93bcb9c85d1ad5592d93fc61967fc90645c Mon Sep 17 00:00:00 2001 From: Endi Date: Tue, 23 Jul 2019 23:23:21 +0700 Subject: [PATCH] refactor(v2): remove unused metadata for pages (#1694) * refactor(v2): remove unused metadata for pages * changelog --- CHANGELOG-2.x.md | 1 + packages/docusaurus-plugin-content-pages/src/index.js | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index 2db457479a..1eb666dc55 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -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. diff --git a/packages/docusaurus-plugin-content-pages/src/index.js b/packages/docusaurus-plugin-content-pages/src/index.js index 1c47cd4d16..58f108a926 100644 --- a/packages/docusaurus-plugin-content-pages/src/index.js +++ b/packages/docusaurus-plugin-content-pages/src/index.js @@ -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, - }, }); }), );