fix: eslint errors
This commit is contained in:
parent
1cfdda4e19
commit
44a95cbf1c
6 changed files with 60 additions and 36 deletions
|
|
@ -24,11 +24,11 @@ export type { Training };
|
|||
|
||||
const root = process.cwd();
|
||||
|
||||
export async function getTrainingFiles() {
|
||||
export function getTrainingFiles() {
|
||||
return fs.readdirSync(path.join(root, 'content', 'training'), 'utf-8');
|
||||
}
|
||||
|
||||
export async function getTrainingBySlug(slug: string, fields: string[] = []) {
|
||||
export function getTrainingBySlug(slug: string) {
|
||||
const source = fs.readFileSync(path.join(root, 'content', 'training', `${slug}.md`), 'utf8');
|
||||
|
||||
const { data, content } = matter(source);
|
||||
|
|
@ -39,21 +39,27 @@ export async function getTrainingBySlug(slug: string, fields: string[] = []) {
|
|||
};
|
||||
}
|
||||
|
||||
export async function getAllTrainingsWithMetadata(): Promise<Training[]> {
|
||||
export function getAllTrainingsWithMetadata(): Training[] {
|
||||
const files = fs.readdirSync(path.join(root, 'content', 'training'))
|
||||
|
||||
// @ts-ignore
|
||||
return files.reduce((allTrainings, fileName) => {
|
||||
const source = fs.readFileSync(path.join(root, 'content', 'training', fileName), 'utf8');
|
||||
const { data, content } = matter(source);
|
||||
const trainings = [] as Training[];
|
||||
|
||||
return [
|
||||
{
|
||||
metadata: data,
|
||||
content: content,
|
||||
},
|
||||
...allTrainings,
|
||||
]
|
||||
}, [])
|
||||
for (const fileName of files) {
|
||||
const source = fs.readFileSync(path.join(root, 'content', 'training', fileName), 'utf8');
|
||||
const { data: metadata, content: content } = matter(source);
|
||||
trainings.push({metadata, content} as Training);
|
||||
}
|
||||
|
||||
return trainings;
|
||||
|
||||
// return files.reduce((allTrainings, fileName) => {
|
||||
// const source = fs.readFileSync(path.join(root, 'content', 'training', fileName), 'utf8');
|
||||
// const training = matter(source);
|
||||
|
||||
// return [
|
||||
// training,
|
||||
// ...allTrainings,
|
||||
// ]
|
||||
// }, [])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export function formatCurrency(price: number | bigint, locale: string = 'en-US', currency: string = 'CZK'): string {
|
||||
export function formatCurrency(price: number | bigint, locale ='en-US', currency = 'CZK'): string {
|
||||
const currencyFormatter = new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
|
|
|
|||
Reference in a new issue