mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 11:07:07 +02:00
refactor(v2): shift plugin cache generation into its own dir
This commit is contained in:
parent
92c7e1f44b
commit
95ca07a646
3 changed files with 9 additions and 5 deletions
|
@ -10,7 +10,7 @@ import {renderRoutes} from 'react-router-config';
|
|||
|
||||
import routes from '@generated/routes'; // eslint-disable-line
|
||||
// TODO: Generalize for blog plugin.
|
||||
import blogMetadata from '@generated/blogMetadata'; // eslint-disable-line
|
||||
import blogMetadata from '@generated/docusaurus-content-blog/blogMetadata.json'; // eslint-disable-line
|
||||
import docsMetadatas from '@generated/docsMetadatas'; // eslint-disable-line
|
||||
import env from '@generated/env'; // eslint-disable-line
|
||||
import docsSidebars from '@generated/docsSidebars'; // eslint-disable-line
|
||||
|
|
|
@ -99,10 +99,12 @@ module.exports = async function load(siteDir) {
|
|||
contents,
|
||||
};
|
||||
contentsStore[options.contentKey] = pluginContents;
|
||||
const pluginCacheDir = path.join(generatedFilesDir, name);
|
||||
fs.ensureDirSync(pluginCacheDir);
|
||||
await generate(
|
||||
generatedFilesDir,
|
||||
options.cachePath,
|
||||
`export default ${JSON.stringify(contents, null, 2)};`,
|
||||
pluginCacheDir,
|
||||
options.cacheFileName,
|
||||
JSON.stringify(contents, null, 2),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
@ -141,5 +143,7 @@ module.exports = async function load(siteDir) {
|
|||
const routesConfig = await genRoutesConfig(props);
|
||||
await generate(generatedFilesDir, 'routes.js', routesConfig);
|
||||
|
||||
await generate(generatedFilesDir, 'routes.js', routesConfig);
|
||||
|
||||
return props;
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ const DEFAULT_OPTIONS = {
|
|||
routeBasePath: 'blog', // URL Route.
|
||||
include: ['*.md'], // Extensions to include.
|
||||
pageCount: 10, // How many entries per page.
|
||||
cachePath: 'blogMetadata.js',
|
||||
cacheFileName: 'blogMetadata.json',
|
||||
};
|
||||
|
||||
class DocusaurusContentBlogPlugin {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue