mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 21:47:01 +02:00
refactor: enable a few TS flags (#6852)
* refactor: enable a few TS flags * refactor * revert to working version * fix * better * change
This commit is contained in:
parent
9f925a42bf
commit
4db0c620de
71 changed files with 210 additions and 174 deletions
|
@ -39,7 +39,7 @@ export default async function lqipLoader(
|
|||
if (contentIsUrlExport) {
|
||||
source = content.match(
|
||||
/^(?:export default|module.exports =) (?<source>.*)/,
|
||||
)!.groups!.source;
|
||||
)!.groups!.source!;
|
||||
} else {
|
||||
if (!contentIsFileExport) {
|
||||
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
||||
|
@ -48,7 +48,7 @@ export default async function lqipLoader(
|
|||
}
|
||||
source = content.match(
|
||||
/^(?:export default|module.exports =) (?<source>.*);/,
|
||||
)!.groups!.source;
|
||||
)!.groups!.source!;
|
||||
}
|
||||
|
||||
const outputPromises: [Promise<string> | null, Promise<string[]> | null] = [
|
||||
|
|
|
@ -25,14 +25,15 @@ const SUPPORTED_MIMES: Record<string, string> = {
|
|||
export async function base64(file: string): Promise<string> {
|
||||
let extension = path.extname(file);
|
||||
extension = extension.split('.').pop()!;
|
||||
const mime = SUPPORTED_MIMES[extension];
|
||||
|
||||
if (!SUPPORTED_MIMES[extension]) {
|
||||
if (!mime) {
|
||||
throw new Error(ERROR_EXT);
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await sharp(file).resize(10).toBuffer();
|
||||
return toBase64(SUPPORTED_MIMES[extension], data);
|
||||
return toBase64(mime, data);
|
||||
} catch (err) {
|
||||
logger.error`Generation of base64 failed for image path=${file}.`;
|
||||
throw err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue