astro-d2 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config.ts CHANGED
@@ -15,6 +15,18 @@ export const AstroD2ConfigSchema = z
15
15
  * @default 'd2'
16
16
  */
17
17
  output: z.string().default('d2'),
18
+ /**
19
+ * The padding (in pixels) around the rendered diagrams.
20
+ *
21
+ * @default 100
22
+ */
23
+ pad: z.number().default(100),
24
+ /**
25
+ * Whether to render the diagrams as if they were sketched by hand.
26
+ *
27
+ * @default false
28
+ */
29
+ sketch: z.boolean().default(false),
18
30
  /**
19
31
  * Whether the Astro D2 integration should skip the generation of diagrams.
20
32
  *
@@ -19,17 +19,16 @@ export const AttributesSchema = z
19
19
  .optional()
20
20
  .transform((value) => (value === 'false' ? false : value)),
21
21
  /**
22
- * The padding (in pixels) around the rendered diagram.
23
- *
24
- * @default 100
22
+ * Overrides the global `pad` configuration for the diagram.
25
23
  */
26
- pad: z.coerce.number().default(100),
24
+ pad: z.coerce.number().optional(),
27
25
  /**
28
- * Whether to render the diagram as if it was sketched by hand.
29
- *
30
- * @default 'false'
26
+ * Overrides the global `sketch` configuration for the diagram.
31
27
  */
32
- sketch: z.union([z.literal('true'), z.literal('false')]).default('false'),
28
+ sketch: z
29
+ .union([z.literal('true'), z.literal('false')])
30
+ .optional()
31
+ .transform((value) => (value === 'false' ? false : value)),
33
32
  /**
34
33
  * Defines the target board to render when using composition.
35
34
  * Use `root` to target the root board.
package/libs/d2.ts CHANGED
@@ -47,8 +47,8 @@ export async function generateD2Diagram(
47
47
  [
48
48
  `--layout=${config.layout}`,
49
49
  `--theme=${attributes.theme ?? config.theme.default}`,
50
- `--sketch=${attributes.sketch}`,
51
- `--pad=${attributes.pad}`,
50
+ `--sketch=${attributes.sketch ?? config.sketch}`,
51
+ `--pad=${attributes.pad ?? config.pad}`,
52
52
  ...extraArgs,
53
53
  '-',
54
54
  outputPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-d2",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "Astro integration and remark plugin to transform D2 Markdown code blocks into diagrams.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",