refactor: ensure lodash is default-imported (#6716)

This commit is contained in:
Joshua Chen 2022-02-19 18:15:02 +08:00 committed by GitHub
parent 47c9a37c5f
commit ea6ceaa371
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 239 additions and 221 deletions

View file

@ -6,7 +6,7 @@
*/
import {createHash} from 'crypto';
import {kebabCase} from 'lodash';
import _ from 'lodash';
import {shortName, isNameTooLong} from './pathUtils';
export function md5Hash(str: string): string {
@ -29,9 +29,9 @@ export function docuHash(str: string): string {
return 'index';
}
const shortHash = simpleHash(str, 3);
const parsedPath = `${kebabCase(str)}-${shortHash}`;
const parsedPath = `${_.kebabCase(str)}-${shortHash}`;
if (isNameTooLong(parsedPath)) {
return `${shortName(kebabCase(str))}-${shortHash}`;
return `${shortName(_.kebabCase(str))}-${shortHash}`;
}
return parsedPath;
}