mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
chore(v2): fix code style (revert previous changes)
This commit is contained in:
parent
1480a7eb80
commit
1f00d15c74
143 changed files with 457 additions and 458 deletions
|
@ -35,15 +35,11 @@ export async function generate(
|
|||
// This is to avoid unnecessary overwriting and we can reuse old file.
|
||||
if (!lastHash && fs.existsSync(filepath)) {
|
||||
const lastContent = await fs.readFile(filepath, 'utf8');
|
||||
lastHash = createHash('md5')
|
||||
.update(lastContent)
|
||||
.digest('hex');
|
||||
lastHash = createHash('md5').update(lastContent).digest('hex');
|
||||
fileHash.set(filepath, lastHash);
|
||||
}
|
||||
|
||||
const currentHash = createHash('md5')
|
||||
.update(content)
|
||||
.digest('hex');
|
||||
const currentHash = createHash('md5').update(content).digest('hex');
|
||||
|
||||
if (lastHash !== currentHash) {
|
||||
await fs.ensureDir(path.dirname(filepath));
|
||||
|
@ -79,7 +75,7 @@ export function fileToPath(file: string): string {
|
|||
export function encodePath(userpath: string): string {
|
||||
return userpath
|
||||
.split('/')
|
||||
.map(item => encodeURIComponent(item))
|
||||
.map((item) => encodeURIComponent(item))
|
||||
.join('/');
|
||||
}
|
||||
|
||||
|
@ -91,10 +87,7 @@ export function docuHash(str: string): string {
|
|||
if (str === '/') {
|
||||
return 'index';
|
||||
}
|
||||
const shortHash = createHash('md5')
|
||||
.update(str)
|
||||
.digest('hex')
|
||||
.substr(0, 3);
|
||||
const shortHash = createHash('md5').update(str).digest('hex').substr(0, 3);
|
||||
return `${kebabCase(str)}-${shortHash}`;
|
||||
}
|
||||
|
||||
|
@ -200,10 +193,7 @@ export function parse(
|
|||
} {
|
||||
const options: {} = {
|
||||
excerpt: (file: matter.GrayMatterFile<string>): void => {
|
||||
file.excerpt = file.content
|
||||
.trim()
|
||||
.split('\n', 1)
|
||||
.shift();
|
||||
file.excerpt = file.content.trim().split('\n', 1).shift();
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue