mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +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
|
@ -51,11 +51,12 @@ import {
|
|||
} from './blogUtils';
|
||||
import {BlogPostFrontMatter} from './blogFrontMatter';
|
||||
import {createBlogFeedFiles} from './feed';
|
||||
import {getAuthorsMapFilePath} from './authors';
|
||||
|
||||
export default function pluginContentBlog(
|
||||
export default async function pluginContentBlog(
|
||||
context: LoadContext,
|
||||
options: PluginOptions,
|
||||
): Plugin<BlogContent> {
|
||||
): Promise<Plugin<BlogContent>> {
|
||||
if (options.admonitions) {
|
||||
options.remarkPlugins = options.remarkPlugins.concat([
|
||||
[admonitions, options.admonitions],
|
||||
|
@ -89,24 +90,23 @@ export default function pluginContentBlog(
|
|||
const aliasedSource = (source: string) =>
|
||||
`~blog/${posixPath(path.relative(pluginDataDirRoot, source))}`;
|
||||
|
||||
const authorsMapFilePath = await getAuthorsMapFilePath({
|
||||
authorsMapPath: options.authorsMapPath,
|
||||
contentPaths,
|
||||
});
|
||||
|
||||
return {
|
||||
name: 'docusaurus-plugin-content-blog',
|
||||
|
||||
getPathsToWatch() {
|
||||
const {include, authorsMapPath} = options;
|
||||
const {include} = options;
|
||||
const contentMarkdownGlobs = getContentPathList(contentPaths).flatMap(
|
||||
(contentPath) => include.map((pattern) => `${contentPath}/${pattern}`),
|
||||
);
|
||||
|
||||
// TODO: we should read this path in plugin! but plugins do not support async init for now :'(
|
||||
// const authorsMapFilePath = await getAuthorsMapFilePath({authorsMapPath,contentPaths,});
|
||||
// simplified impl, better than nothing for now:
|
||||
const authorsMapFilePath = path.join(
|
||||
contentPaths.contentPath,
|
||||
authorsMapPath,
|
||||
);
|
||||
|
||||
return [authorsMapFilePath, ...contentMarkdownGlobs];
|
||||
return [authorsMapFilePath, ...contentMarkdownGlobs].filter(
|
||||
Boolean,
|
||||
) as string[];
|
||||
},
|
||||
|
||||
async getTranslationFiles() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue