mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-01 16:00:29 +02:00
refactor: remove a few Lodash usages & ESLint enforcement (#5807)
* refactor: remove some lodash usage Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Enforce ESLint Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * More forbids * Fixup * Fix * Fix website
This commit is contained in:
parent
4b2152a964
commit
7a6607cfa1
12 changed files with 60 additions and 49 deletions
|
@ -9,7 +9,7 @@ import fs from 'fs-extra';
|
|||
import chalk from 'chalk';
|
||||
import path from 'path';
|
||||
import readingTime from 'reading-time';
|
||||
import {compact, keyBy, mapValues} from 'lodash';
|
||||
import {keyBy, mapValues} from 'lodash';
|
||||
import {
|
||||
PluginOptions,
|
||||
BlogPost,
|
||||
|
@ -267,7 +267,7 @@ export async function generateBlogPosts(
|
|||
authorsMapPath: options.authorsMapPath,
|
||||
});
|
||||
|
||||
const blogPosts: BlogPost[] = compact(
|
||||
const blogPosts = (
|
||||
await Promise.all(
|
||||
blogSourceFiles.map(async (blogSourceFile: string) => {
|
||||
try {
|
||||
|
@ -287,8 +287,8 @@ export async function generateBlogPosts(
|
|||
throw e;
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
)
|
||||
).filter(Boolean) as BlogPost[];
|
||||
|
||||
blogPosts.sort(
|
||||
(a, b) => b.metadata.date.getTime() - a.metadata.date.getTime(),
|
||||
|
|
|
@ -22,7 +22,6 @@ import {
|
|||
DEFAULT_PLUGIN_ID,
|
||||
} from '@docusaurus/core/lib/constants';
|
||||
import {translateContent, getTranslationFiles} from './translations';
|
||||
import {flatten, take} from 'lodash';
|
||||
|
||||
import {
|
||||
PluginOptions,
|
||||
|
@ -98,10 +97,8 @@ export default function pluginContentBlog(
|
|||
|
||||
getPathsToWatch() {
|
||||
const {include, authorsMapPath} = options;
|
||||
const contentMarkdownGlobs = flatten(
|
||||
getContentPathList(contentPaths).map((contentPath) => {
|
||||
return include.map((pattern) => `${contentPath}/${pattern}`);
|
||||
}),
|
||||
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 :'(
|
||||
|
@ -244,7 +241,7 @@ export default function pluginContentBlog(
|
|||
const sidebarBlogPosts =
|
||||
options.blogSidebarCount === 'ALL'
|
||||
? blogPosts
|
||||
: take(blogPosts, options.blogSidebarCount);
|
||||
: blogPosts.slice(0, options.blogSidebarCount);
|
||||
|
||||
const archiveUrl = normalizeUrl([
|
||||
baseUrl,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue