mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-24 06:27:02 +02:00
refactor: unify export directive style (#6751)
This commit is contained in:
parent
0c807b3501
commit
0d14470d54
105 changed files with 315 additions and 510 deletions
|
@ -13,7 +13,7 @@ type Options = {
|
|||
palette: boolean;
|
||||
};
|
||||
|
||||
async function lqipLoader(
|
||||
export default async function lqipLoader(
|
||||
this: LoaderContext<Options>,
|
||||
contentBuffer: Buffer,
|
||||
): Promise<void> {
|
||||
|
@ -78,5 +78,3 @@ async function lqipLoader(
|
|||
}
|
||||
|
||||
lqipLoader.raw = true;
|
||||
|
||||
export default lqipLoader;
|
||||
|
|
|
@ -21,7 +21,7 @@ const SUPPORTED_MIMES: Record<string, string> = {
|
|||
png: 'image/png',
|
||||
};
|
||||
|
||||
async function base64(file: string): Promise<string> {
|
||||
export async function base64(file: string): Promise<string> {
|
||||
let extension = path.extname(file) || '';
|
||||
extension = extension.split('.').pop()!;
|
||||
|
||||
|
@ -36,7 +36,7 @@ async function base64(file: string): Promise<string> {
|
|||
throw new Error('Unhandled promise rejection in base64 promise');
|
||||
}
|
||||
|
||||
async function palette(file: string): Promise<string[]> {
|
||||
export async function palette(file: string): Promise<string[]> {
|
||||
const vibrant = new Vibrant(file, {});
|
||||
const pal = await vibrant.getPalette();
|
||||
if (pal) {
|
||||
|
@ -48,5 +48,3 @@ async function palette(file: string): Promise<string[]> {
|
|||
process.on('unhandledRejection', (up) => {
|
||||
throw up;
|
||||
});
|
||||
|
||||
export {base64, palette};
|
||||
|
|
|
@ -12,14 +12,14 @@ import type {Palette} from 'node-vibrant/lib/color';
|
|||
* it returns a Base64 image string with required formatting
|
||||
* to work on the web (<img src=".." /> or in CSS url('..'))
|
||||
*/
|
||||
const toBase64 = (extMimeType: string, data: Buffer): string =>
|
||||
export const toBase64 = (extMimeType: string, data: Buffer): string =>
|
||||
`data:${extMimeType};base64,${data.toString('base64')}`;
|
||||
|
||||
/**
|
||||
* takes a color swatch object, converts it to an array & returns
|
||||
* only hex color
|
||||
*/
|
||||
const toPalette = (swatch: Palette): string[] => {
|
||||
export const toPalette = (swatch: Palette): string[] => {
|
||||
let palette = Object.keys(swatch).reduce((result, key) => {
|
||||
if (swatch[key] !== null) {
|
||||
result.push({
|
||||
|
@ -32,5 +32,3 @@ const toPalette = (swatch: Palette): string[] => {
|
|||
palette = _.sortBy(palette, ['popularity']);
|
||||
return palette.map((color) => color.hex).reverse();
|
||||
};
|
||||
|
||||
export {toBase64, toPalette};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue