astro-d2 0.4.0 → 0.5.1
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/index.ts +11 -1
- package/libs/attributes.ts +4 -0
- package/libs/d2.ts +1 -1
- package/libs/remark.ts +3 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -45,7 +45,17 @@ export default function astroD2Integration(userConfig?: AstroD2UserConfig): Astr
|
|
|
45
45
|
|
|
46
46
|
updateConfig({
|
|
47
47
|
markdown: {
|
|
48
|
-
remarkPlugins: [
|
|
48
|
+
remarkPlugins: [
|
|
49
|
+
[
|
|
50
|
+
remarkAstroD2,
|
|
51
|
+
{
|
|
52
|
+
...config,
|
|
53
|
+
base: astroConfig.base,
|
|
54
|
+
publicDir: astroConfig.publicDir,
|
|
55
|
+
root: astroConfig.root,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
],
|
|
49
59
|
},
|
|
50
60
|
})
|
|
51
61
|
},
|
package/libs/attributes.ts
CHANGED
|
@@ -18,6 +18,10 @@ export const AttributesSchema = z
|
|
|
18
18
|
.string()
|
|
19
19
|
.optional()
|
|
20
20
|
.transform((value) => (value === 'false' ? false : value)),
|
|
21
|
+
/**
|
|
22
|
+
* Overrides the global `layout` configuration for the diagram.
|
|
23
|
+
*/
|
|
24
|
+
layout: z.union([z.literal('dagre'), z.literal('elk'), z.literal('tala')]).optional(),
|
|
21
25
|
/**
|
|
22
26
|
* Overrides the global `pad` configuration for the diagram.
|
|
23
27
|
*/
|
package/libs/d2.ts
CHANGED
|
@@ -63,7 +63,7 @@ export async function generateD2Diagram(
|
|
|
63
63
|
await exec(
|
|
64
64
|
'd2',
|
|
65
65
|
[
|
|
66
|
-
`--layout=${config.layout}`,
|
|
66
|
+
`--layout=${attributes.layout ?? config.layout}`,
|
|
67
67
|
`--theme=${attributes.theme ?? config.theme.default}`,
|
|
68
68
|
`--sketch=${attributes.sketch ?? config.sketch}`,
|
|
69
69
|
`--pad=${attributes.pad ?? config.pad}`,
|
package/libs/remark.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
+
import url from 'node:url'
|
|
2
3
|
|
|
3
4
|
import type { Code, Html, Parent, Root } from 'mdast'
|
|
4
5
|
import { SKIP, visit } from 'unist-util-visit'
|
|
@@ -83,7 +84,7 @@ function getOutputPaths(config: RemarkAstroD2Config, file: VFile, nodeIndex: num
|
|
|
83
84
|
const relativeOutputPath = path.join(parsedRelativePath.dir, `${parsedRelativePath.name}-${nodeIndex}.svg`)
|
|
84
85
|
|
|
85
86
|
return {
|
|
86
|
-
fsPath: path.join(
|
|
87
|
+
fsPath: path.join(url.fileURLToPath(config.publicDir), config.output, relativeOutputPath),
|
|
87
88
|
imgPath: path.posix.join(config.base, config.output, relativeOutputPath),
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -109,5 +110,6 @@ interface VisitorContext {
|
|
|
109
110
|
|
|
110
111
|
export interface RemarkAstroD2Config extends AstroD2Config {
|
|
111
112
|
base: string
|
|
113
|
+
publicDir: URL
|
|
112
114
|
root: URL
|
|
113
115
|
}
|
package/package.json
CHANGED