-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmith.ts
More file actions
68 lines (62 loc) · 1.5 KB
/
Copy pathsmith.ts
File metadata and controls
68 lines (62 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { dirname } from 'node:path'
import { env } from 'node:process'
import { fileURLToPath } from 'node:url'
import layouts from '@metalsmith/layouts'
import metadata from '@metalsmith/metadata'
import { blueprint, getHandlebarsPartials } from '@seamapi/smith'
import * as types from '@seamapi/types/connect'
import { deleteAsync } from 'del'
import Metalsmith from 'metalsmith'
import { apiReferenceRoot } from './lib/config.js'
import {
formatCode,
helpers,
postprocess,
reference,
report,
summary,
} from './lib/index.js'
const rootDir = dirname(fileURLToPath(import.meta.url))
await Promise.all([
deleteAsync([
`./${apiReferenceRoot}/**`,
`!./${apiReferenceRoot}/SUMMARY.md`,
`!./${apiReferenceRoot}/.gitbook.yaml`,
]),
])
const partials = await getHandlebarsPartials(`${rootDir}/layouts/partials`)
Metalsmith(rootDir)
.source('./source')
.destination('../')
.clean(false)
.use(
metadata({
codeSampleDefinitions: './data/code-sample-definitions',
resourceSampleDefinitions: './data/resource-sample-definitions',
pathMetadata: './data/paths.yaml',
}),
)
.use(
blueprint({
types,
formatCode,
skipCodeFormat: env['SKIP_CODE_FORMAT'] != null,
}),
)
.use(reference)
.use(report)
.use(
layouts({
default: 'default.hbs',
engineOptions: {
noEscape: true,
helpers,
partials,
},
}),
)
.use(postprocess)
.use(summary)
.build((err) => {
if (err != null) throw err
})