|
1 | 1 | /** |
2 | 2 | * @import {Root} from 'hast' |
3 | | - * @import {DataMap, VFile} from 'vfile' |
| 3 | + * @import {DataMap} from 'vfile' |
4 | 4 | * @import {Human} from '../data/humans.js' |
5 | 5 | * @import {Release} from '../data/releases.js' |
6 | 6 | * @import {Person as Sponsor} from '../data/sponsors.js' |
@@ -32,8 +32,9 @@ import yaml from 'yaml' |
32 | 32 | import {glob} from 'glob' |
33 | 33 | import {matter} from 'vfile-matter' |
34 | 34 | import all from 'p-all' |
35 | | -import {toVFile, read, readSync, write} from 'to-vfile' |
| 35 | +import {read, write} from 'to-vfile' |
36 | 36 | import {reporter} from 'vfile-reporter' |
| 37 | +import {VFile} from 'vfile' |
37 | 38 | import {humans} from '../data/humans.js' |
38 | 39 | import {releases as dataReleases} from '../data/releases.js' |
39 | 40 | import {sponsors} from '../data/sponsors.js' |
@@ -79,27 +80,29 @@ await expandReleases(dataReleases) |
79 | 80 |
|
80 | 81 | const input = await glob('doc/learn/**/*.md') |
81 | 82 |
|
82 | | -const entries = input.map(function (input) { |
83 | | - const file = readSync(input) |
84 | | - matter(file) |
85 | | - const slug = path.basename(input, path.extname(input)) |
86 | | - let meta = file.data.meta |
87 | | - |
88 | | - if (!meta) { |
89 | | - meta = {} |
90 | | - file.data.meta = meta |
91 | | - } |
92 | | - |
93 | | - assert(file.data.matter) |
94 | | - const {group, tags} = file.data.matter || {} |
95 | | - assert(typeof group === 'string') |
96 | | - meta.type = 'article' |
97 | | - meta.tags = [group] |
98 | | - if (tags) meta.tags.push(...tags) |
99 | | - meta.pathname = ['', 'learn', group, slug, ''].join('/') |
100 | | - |
101 | | - return file |
102 | | -}) |
| 83 | +const entries = await Promise.all( |
| 84 | + input.map(async function (input) { |
| 85 | + const file = await read(input) |
| 86 | + matter(file) |
| 87 | + const slug = path.basename(input, path.extname(input)) |
| 88 | + let meta = file.data.meta |
| 89 | + |
| 90 | + if (!meta) { |
| 91 | + meta = {} |
| 92 | + file.data.meta = meta |
| 93 | + } |
| 94 | + |
| 95 | + assert(file.data.matter) |
| 96 | + const {group, tags} = file.data.matter || {} |
| 97 | + assert(typeof group === 'string') |
| 98 | + meta.type = 'article' |
| 99 | + meta.tags = [group] |
| 100 | + if (tags) meta.tags.push(...tags) |
| 101 | + meta.pathname = ['', 'learn', group, slug, ''].join('/') |
| 102 | + |
| 103 | + return file |
| 104 | + }) |
| 105 | +) |
103 | 106 |
|
104 | 107 | const sections = [ |
105 | 108 | { |
@@ -313,7 +316,7 @@ all(promises, {concurrency: 50}) |
313 | 316 | */ |
314 | 317 | function page(render, meta) { |
315 | 318 | tasks.push(function () { |
316 | | - return {tree: render(), file: toVFile({data: {meta}})} |
| 319 | + return {tree: render(), file: new VFile({data: {meta}})} |
317 | 320 | }) |
318 | 321 | } |
319 | 322 |
|
|
0 commit comments