Pad static generation logging figures

This commit is contained in:
Sam Becker 2025-03-18 21:28:12 -05:00
parent 4b9077fa9c
commit a2271bbf33
2 changed files with 12 additions and 4 deletions

View File

@ -12,8 +12,10 @@ import { depluralize, pluralize } from '@/utility/string';
type StaticOutput = 'page' | 'image';
const logStaticGenerationDetails = (count: number, content: string) =>
console.log(`Statically generating ${pluralize(count, content)} ...`);
const logStaticGenerationDetails = (count: number, content: string) => {
const label = pluralize(count, content, undefined, 3);
console.log(`Statically generating ${label} ...`);
};
export const staticallyGeneratePhotosIfConfigured = (type: StaticOutput) =>
IS_PRODUCTION && (

View File

@ -44,8 +44,14 @@ export const pluralize = (
count: number,
singular: string,
plural?: string,
) =>
`${count} ${count === 1 ? singular : plural ?? `${singular}s`}`;
padPlaces = 0,
) =>{
const numberFormatted = padPlaces
? String(count).padStart(padPlaces, '0')
: count;
const label = count === 1 ? singular : plural ?? `${singular}s`;
return `${numberFormatted} ${label}`;
};
export const depluralize = (string: string) =>
// Handle plurals like "lenses"