{"size": 718, "ext": "js", "max_stars_repo_path": "lib/utils/load-page.js", "max_stars_repo_name": "pxgrid/ui-spec-md", "max_stars_repo_stars_event_min_datetime": "2016-05-13T10:00:07.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-28T10:29:27.000Z", "max_issues_repo_path": "lib/utils/load-page.js", "max_issues_repo_name": "pxgrid/ui-spec-md", "max_issues_repo_issues_event_min_datetime": "2016-04-15T13:19:08.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-09T08:17:32.000Z", "max_forks_repo_path": "lib/utils/load-page.js", "max_forks_repo_name": "pxgrid/ui-spec-md", "max_forks_repo_forks_event_min_datetime": "2016-07-14T04:32:11.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-17T10:05:16.000Z"}
{"max_stars_count": 9, "max_issues_count": 86, "max_forks_count": 3, "avg_line_length": 29.9166666667, "max_line_length": 78, "alphanum_fraction": 0.7005571031}
const gitLog = require('../utils/git-log')
const readFile = require('../utils/read-file')
const parsePageMd = require('../parse-page-md')

/**
 * Markdownのファイルを読み込んで、Pageという概念にモデル化する。
 *
 * - 最後に更新した情報を`git log`
 * - Markdownのテキスト
 * この2つを持つ。
 *
 */
async function loadPage({ rootDir, mdPath, destFromSeverRoot }) {
  const md = await readFile(mdPath)
  const log = await gitLog(mdPath).catch(error => {
    // If there is no repository or git is not installed, an error will occur.
    console.warn(`Could not get information from git. (${mdPath})`)
    return parsePageMd(md, {}, rootDir, mdPath, destFromSeverRoot)
  })
  return parsePageMd(md, log, rootDir, mdPath, destFromSeverRoot)
}

module.exports = loadPage
