summaryrefslogtreecommitdiffstats
path: root/packages/gitbook/src/parse/lookupStructureFile.js
blob: 17af9a1ccb658d212f94145a72f9472b1c843e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const findParsableFile = require('./findParsableFile');

/**
 * Lookup a structure file (ex: SUMMARY.md, GLOSSARY.md) in a book. Uses
 * book's config to find it.
 *
 * @param {Book} book
 * @param {String} type: one of ["glossary", "readme", "summary", "langs"]
 * @return {Promise<File | Undefined>} The path of the file found, relative
 * to the book content root.
 */
function lookupStructureFile(book, type) {
    const { config } = book;
    const fileToSearch = config.getValue(['structure', type]);

    return findParsableFile(book, fileToSearch);
}

module.exports = lookupStructureFile;