function getLangProgress()

in src/LangList.js [9:33]


function getLangProgress(lang, issue) {
  const {
    corePages = 'Core Pages',
    nextSteps = 'Next Steps',
    ...langProps
  } = lang
  const { body, createdAt, lastEditedAt = createdAt, ...issueProps } = issue
  const sections = {}
  body.split(/^##\s+/gm).forEach(section => {
    const [heading, ...content] = section.split('\n')
    const items = content.filter(line => {
      return /\* *\[[ x]\]/.test(line)
    })
    const finishedItems = items.filter(line => /\* \[x\]/.test(line))
    sections[heading.trim()] = finishedItems.length / items.length
  })
  return {
    ...langProps,
    ...issueProps,
    createdAt,
    lastEditedAt,
    coreCompletion: sections[corePages],
    otherCompletion: sections[nextSteps],
  }
}