carbon-components-svelte/scripts/build-docs.js
Enrico Sacchetti 0ac2faa8bc
chore: set up docs
- BREAKING CHANGE: set peerDependencies for Svelte 3 minimum versino to 3.30.0 to support `SvelteComponent` type
- Us ESM style for docs script
2023-07-07 22:25:18 -04:00

27 lines
666 B
JavaScript

import fs from "node:fs";
import glob from "glob";
import { sveld } from "sveld";
import pkg from "../package.json" assert { type: "json" };
sveld({
glob: true,
markdown: true,
markdownOptions: {
onAppend: (type, document, components) => {
if (type === "h1")
document.append(
"quote",
`${components.size} components exported from ${pkg.name}@${pkg.version}.`
);
},
},
json: true,
jsonOptions: {
outFile: "docs/src/COMPONENT_API.json",
},
});
glob.sync("./src/**/*.d.ts").forEach((file) => {
console.log("Copying", file, " to types/");
fs.copyFileSync(file, file.replace(/src/, "types"));
});