mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-22 20:47:53 +02:00
feat: async plugin creator functions (#6166)
This commit is contained in:
parent
f8a670966e
commit
b393700a61
17 changed files with 90 additions and 79 deletions
|
@ -16,7 +16,7 @@ describe('docusaurus-plugin-content-pages', () => {
|
|||
const siteDir = path.join(__dirname, '__fixtures__', 'website');
|
||||
const context = await loadContext(siteDir);
|
||||
const pluginPath = 'src/pages';
|
||||
const plugin = pluginContentPages(
|
||||
const plugin = await pluginContentPages(
|
||||
context,
|
||||
normalizePluginOptions({
|
||||
path: pluginPath,
|
||||
|
@ -77,7 +77,7 @@ describe('docusaurus-plugin-content-pages', () => {
|
|||
const siteDir = path.join(__dirname, '__fixtures__', 'website');
|
||||
const context = await loadContext(siteDir);
|
||||
const pluginPath = 'src/pages';
|
||||
const plugin = pluginContentPages(
|
||||
const plugin = await pluginContentPages(
|
||||
{
|
||||
...context,
|
||||
i18n: {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import {
|
||||
encodePath,
|
||||
|
@ -45,10 +45,10 @@ export function getContentPathList(contentPaths: PagesContentPaths): string[] {
|
|||
const isMarkdownSource = (source: string) =>
|
||||
source.endsWith('.md') || source.endsWith('.mdx');
|
||||
|
||||
export default function pluginContentPages(
|
||||
export default async function pluginContentPages(
|
||||
context: LoadContext,
|
||||
options: PluginOptions,
|
||||
): Plugin<LoadedContent | null> {
|
||||
): Promise<Plugin<LoadedContent | null>> {
|
||||
if (options.admonitions) {
|
||||
options.remarkPlugins = options.remarkPlugins.concat([
|
||||
[admonitions, options.admonitions || {}],
|
||||
|
@ -90,7 +90,7 @@ export default function pluginContentPages(
|
|||
async loadContent() {
|
||||
const {include} = options;
|
||||
|
||||
if (!fs.existsSync(contentPaths.contentPath)) {
|
||||
if (!(await fs.pathExists(contentPaths.contentPath))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue