mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-04 09:05:49 -05:00
* refactor: explicit types for validate * refactor: explicit return types for ui-components * refactor: use exec instead of match * refactor: add lots more boundary types * refactor: more eslint warnings * refactor: more explicit exports * refactor: more explicit types * refactor: even more explicit types * fix: relax type contrainsts for superblock-order * refactor: final boundaries * refactor: avoid using 'object' type * fix: use named import for captureException This uses TypeScript (which works) instead of import/namespace (which doesn't) to check if captureException exists in sentry/gatsby (it does)
18 lines
490 B
TypeScript
18 lines
490 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; fileData: string }> => {
|
|
const filePath = join(CHALLENGE_DIR, sup, block, step);
|
|
|
|
const fileData = await readFile(filePath, 'utf8');
|
|
const name = matter(fileData).data.title as string;
|
|
|
|
return { name, fileData };
|
|
};
|