mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-05 21:03:24 -05:00
18 lines
586 B
TypeScript
18 lines
586 B
TypeScript
import { readFile } from 'fs/promises';
|
|
import { join } from 'path';
|
|
import matter from 'gray-matter';
|
|
import { CHALLENGE_DIR } from '../configs/paths';
|
|
|
|
export const getStepContent = async (
|
|
sup: string,
|
|
block: string,
|
|
step: string
|
|
): Promise<{ name: string; dashedName: string; fileData: string }> => {
|
|
const filePath = join(CHALLENGE_DIR, sup, block, step);
|
|
|
|
const fileData = await readFile(filePath, 'utf8');
|
|
const name = matter(fileData).data.title as string;
|
|
const dashedName = matter(fileData).data.dashedName as string;
|
|
return { name, dashedName, fileData };
|
|
};
|