|
1 | 1 | /**
|
2 | 2 | * @import {Root} from 'hast'
|
3 | 3 | * @import {DataMap} from 'vfile'
|
| 4 | + * @import {Entry as SitemapEntry} from 'xast-util-sitemap' |
4 | 5 | * @import {Human} from '../data/humans.js'
|
5 | 6 | * @import {Release} from '../data/releases.js'
|
6 | 7 | * @import {Person as Sponsor} from '../data/sponsors.js'
|
@@ -32,6 +33,8 @@ import {read, write} from 'to-vfile'
|
32 | 33 | import {matter} from 'vfile-matter'
|
33 | 34 | import {reporter} from 'vfile-reporter'
|
34 | 35 | import {VFile} from 'vfile'
|
| 36 | +import {sitemap} from 'xast-util-sitemap' |
| 37 | +import {toXml} from 'xast-util-to-xml' |
35 | 38 | import yaml from 'yaml'
|
36 | 39 | import {humans} from '../data/humans.js'
|
37 | 40 | import {releases as dataReleases} from '../data/releases.js'
|
@@ -411,13 +414,29 @@ page(
|
411 | 414 | }
|
412 | 415 | )
|
413 | 416 |
|
| 417 | +/** @type {Array<SitemapEntry>} */ |
| 418 | +const sitemapEntries = [] |
| 419 | + |
414 | 420 | for (const render of tasks) {
|
415 | 421 | const {tree, file} = await render()
|
416 | 422 | file.value = pipeline.stringify(await pipeline.run(tree, file), file)
|
417 | 423 | await write(file)
|
418 |
| - console.log(reporter(file)) |
| 424 | + console.error(reporter(file)) |
| 425 | + const meta = file.data.meta || {} |
| 426 | + const matter = file.data.matter || {} |
| 427 | + const pathname = matter.pathname || meta.pathname |
| 428 | + const modified = matter.modified || meta.modified |
| 429 | + assert(pathname) |
| 430 | + sitemapEntries.push({url: new URL(pathname, origin).href, modified}) |
419 | 431 | }
|
420 | 432 |
|
| 433 | +await fs.writeFile( |
| 434 | + new URL('../build/sitemap.xml', import.meta.url), |
| 435 | + toXml(sitemap(sitemapEntries)) |
| 436 | +) |
| 437 | + |
| 438 | +console.log('✔ `/sitemap.xml`') |
| 439 | + |
421 | 440 | /**
|
422 | 441 | *
|
423 | 442 | * @param {() => Root} render
|
|
0 commit comments