readSrcBook function

Future<SrcBook> readSrcBook(
  1. String folderPath,
  2. String folderName
)

read src book

Implementation

Future<SrcBook> readSrcBook(String folderPath, String folderName) async {
  final path = '$folderPath/$folderName';

  final pageFiles = await readSubFileNames(path);
  final List<SrcPage> pages = [];
  for (final pageFile in pageFiles) {
    // ignore non-md file
    final fileIsMd = pageFile.endsWith(mdExt);
    if (!fileIsMd) continue;
    final page = await readSrcPage(path, pageFile);
    pages.add(page);
  }
  final book = SrcBook(
    name: folderName,
    pages: pages,
  );
  return book;
}