message: refactor: clean up static document script
diff: @@ -16,25 +16,31 @@ export default {
  async function getStaticDocuments(): Promise<Document[]> {
  const paths = await getMarkdownPaths(DOCUMENTS_DIR);
  - return Promise.all(paths.map(async path => {
  - const markdown = await readMarkdown(path);
  + return Promise.all(paths.map(toDocument));
  +}
  +
  +const getMarkdownPaths = (cwd: string): Promise<string[]> =>
  + glob('**/*.md', {
  + absolute: true,
  + cwd
  + });
  +
  +const toDocument = async (path: string) => {
  + return {
  + path: path.replace(/md$/, 'json'),
  + ...renderMarkdown(await readMarkdown(path))
  + };
  +};
  +
  +const renderMarkdown = (markdown: string) => {
  const { body, attributes } = frontMatter(markdown);
  return {
  ...attributes,
  - body: markdownRenderer(body),
  - path: (path as string).replace(/md$/, 'json')
  + body: markdownRenderer(body)
  + };
  };
  - }));
  -}
  const readMarkdown = (path: string): Promise<string> =>
  fs.readFile(path, {
  encoding: 'utf8'
  });
  -
  -const getMarkdownPaths = (cwd: string): Promise<string[]> =>
  - glob('**/*.md', {
  - absolute: true,
  - cwd
  - });
  -
  