-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrecipeReferencePlugin.ts
More file actions
93 lines (81 loc) · 3.29 KB
/
Copy pathrecipeReferencePlugin.ts
File metadata and controls
93 lines (81 loc) · 3.29 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import type { StarlightPlugin } from "@astrojs/starlight/types";
import * as fs from "fs";
import { jsonschemaToMarkdown } from "../lib/jsonschemaToMarkdown";
import type { JSONSchema } from "json-schema-typed";
const topV1 = `
---
title: recipe.yml (v1)
description: A \`recipe.yml\` file is used to configure a custom image.
---
A \`recipe.yml\` file describes the build process of a custom image. The top-level keys set the metadata and base for the image, and modules are build steps that add things on top of the base.
:::tip
This is the reference page for Recipe V1. We recommend using Recipe V2 instead. See the [Recipe V2 reference page](/reference/recipe-v2/). Don't know what this means or how to migrate from V1 to V2? Read the blog post: [Introducing Recipe V2](/blog/recipe-v2)
:::
:::tip
You can add the lines below to the top of your recipe to get yaml completion in your favorite editor.
\`\`\`
# yaml-language-server: $schema=https://schema.blue-build.org/recipe-v1.json
\`\`\`
:::
## Reference
`;
const topV2 = `
---
title: recipe.yml
description: A \`recipe.yml\` file is used to configure a custom image.
---
A \`recipe.yml\` file describes the build process of a custom image. One recipe file corresponds to one published image. Every recipe file specifies the full metadata, base image, and build process of a custom image.
:::tip
This is the reference page for Recipe V2. If you're still on V1, see the [Recipe V1 reference page](/reference/recipe-v1/). Don't know what this means? Read the blog post: [Introducing Recipe V2](/blog/recipe-v2)
:::
:::tip
You can add the lines below to the top of your recipe to get yaml completion in your favorite editor.
\`\`\`
# yaml-language-server: $schema=https://schema.blue-build.org/recipe-v2.json
\`\`\`
:::
## Reference
`;
export default function recipeReferencePlugin(): StarlightPlugin {
return {
name: "recipeReferencePlugin",
hooks: {
async setup() {
{
const outputPath = "src/content/docs/reference/recipe-v1.mdx";
const schemaURL = "https://schema.blue-build.org/recipe-v1.json";
console.log("Fetching recipe schema...");
const schema = (await (await fetch(schemaURL)).json()) as Exclude<
JSONSchema,
boolean
>;
console.log("Recipe schema fetched.");
const markdown = jsonschemaToMarkdown(schema, {
includeDescription: false,
includeType: false,
useLevel: false,
});
console.log("Recipe reference generated.");
await fs.promises.writeFile(outputPath, topV1 + markdown);
}
{
const outputPath = "src/content/docs/reference/recipe.mdx";
const schemaURL = "https://schema.blue-build.org/recipe-v2.json";
console.log("Fetching recipe schema...");
const schema = (await (await fetch(schemaURL)).json()) as Exclude<
JSONSchema,
boolean
>;
console.log("Recipe schema fetched.");
const markdown = jsonschemaToMarkdown(schema, {
includeDescription: false,
includeType: false,
useLevel: false,
});
console.log("Recipe reference generated.");
await fs.promises.writeFile(outputPath, topV2 + markdown);
}
},
},
};
}