style: auto fix.
This commit is contained in:
@ -1,23 +1,33 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const pipe =
|
||||
(...fns) =>
|
||||
(x) =>
|
||||
fns.reduce((v, f) => f(v), x)
|
||||
fns.reduce((v, f) => f(v), x);
|
||||
|
||||
const flattenArray = (input) =>
|
||||
input.reduce((acc, item) => [...acc, ...(Array.isArray(item) ? item : [item])], [])
|
||||
input.reduce(
|
||||
(acc, item) => [...acc, ...(Array.isArray(item) ? item : [item])],
|
||||
[]
|
||||
);
|
||||
|
||||
const map = (fn) => (input) => input.map(fn)
|
||||
const map = (fn) => (input) => input.map(fn);
|
||||
|
||||
const walkDir = (fullPath: string) => {
|
||||
return fs.statSync(fullPath).isFile() ? fullPath : getAllFilesRecursively(fullPath)
|
||||
}
|
||||
return fs.statSync(fullPath).isFile()
|
||||
? fullPath
|
||||
: getAllFilesRecursively(fullPath);
|
||||
};
|
||||
|
||||
const pathJoinPrefix = (prefix: string) => (extraPath: string) => path.join(prefix, extraPath)
|
||||
const pathJoinPrefix = (prefix: string) => (extraPath: string) =>
|
||||
path.join(prefix, extraPath);
|
||||
|
||||
const getAllFilesRecursively = (folder: string): string[] =>
|
||||
pipe(fs.readdirSync, map(pipe(pathJoinPrefix(folder), walkDir)), flattenArray)(folder)
|
||||
pipe(
|
||||
fs.readdirSync,
|
||||
map(pipe(pathJoinPrefix(folder), walkDir)),
|
||||
flattenArray
|
||||
)(folder);
|
||||
|
||||
export default getAllFilesRecursively
|
||||
export default getAllFilesRecursively;
|
||||
|
@ -1,14 +1,14 @@
|
||||
import siteMetadata from '@/data/siteMetadata'
|
||||
import siteMetadata from '@/data/siteMetadata';
|
||||
|
||||
const formatDate = (date: string) => {
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}
|
||||
const now = new Date(date).toLocaleDateString(siteMetadata.locale, options)
|
||||
};
|
||||
const now = new Date(date).toLocaleDateString(siteMetadata.locale, options);
|
||||
|
||||
return now
|
||||
}
|
||||
return now;
|
||||
};
|
||||
|
||||
export default formatDate
|
||||
export default formatDate;
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { replace } = ''
|
||||
const { replace } = '';
|
||||
|
||||
// escape
|
||||
const ca = /[&<>'"]/g
|
||||
const ca = /[&<>'"]/g;
|
||||
|
||||
const esca = {
|
||||
'&': '&',
|
||||
@ -9,8 +9,8 @@ const esca = {
|
||||
'>': '>',
|
||||
"'": ''',
|
||||
'"': '"',
|
||||
}
|
||||
const pe = (m: keyof typeof esca) => esca[m]
|
||||
};
|
||||
const pe = (m: keyof typeof esca) => esca[m];
|
||||
|
||||
/**
|
||||
* Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`.
|
||||
@ -19,4 +19,4 @@ const pe = (m: keyof typeof esca) => esca[m]
|
||||
* the input type is unexpected, except for boolean and numbers,
|
||||
* converted as string.
|
||||
*/
|
||||
export const escape = (es: string): string => replace.call(es, ca, pe)
|
||||
export const escape = (es: string): string => replace.call(es, ca, pe);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { slug } from 'github-slugger'
|
||||
import { slug } from 'github-slugger';
|
||||
|
||||
const kebabCase = (str: string) => slug(str)
|
||||
const kebabCase = (str: string) => slug(str);
|
||||
|
||||
export default kebabCase
|
||||
export default kebabCase;
|
||||
|
Reference in New Issue
Block a user