@magidoc/plugin-starter-variables
Advanced tools
Comparing version 2.2.2 to 2.3.0
@@ -5,6 +5,6 @@ import templates from './variables/templates'; | ||
import type { Variable } from './variables/variable'; | ||
import type { Page } from './variables/templates'; | ||
import type { Page, ExternalLink } from './variables/templates'; | ||
export type { Variable, Page, ExternalLink }; | ||
export { templates }; | ||
export { magidoc }; | ||
export type { Variable, Page }; | ||
export { toVariablesFile, UnsupportedVariablesError }; |
@@ -5,2 +5,8 @@ export declare type Page = { | ||
}; | ||
export declare type ExternalLink = { | ||
label: string; | ||
href: string; | ||
kind?: string; | ||
group?: string; | ||
}; | ||
declare const _default: { | ||
@@ -14,3 +20,4 @@ APP_LOGO: import("./variable").Variable<string>; | ||
PAGES: import("./variable").Variable<(Page | undefined)[]>; | ||
EXTERNAL_LINKS: import("./variable").Variable<(ExternalLink | undefined)[]>; | ||
}; | ||
export default _default; |
@@ -21,7 +21,15 @@ import { stringConverter } from './converters/string.js'; | ||
const type = zod.lazy(() => zod.object({ | ||
title: zod.string().nonempty(), | ||
content: zod.union([zod.array(type), zod.string().nonempty()]), | ||
title: zod.string().min(1), | ||
content: zod.union([zod.array(type), zod.string().min(1)]), | ||
})); | ||
return type; | ||
})), | ||
EXTERNAL_LINKS: createVariable('EXTERNAL_LINKS', arrayConverter((zod) => { | ||
return zod.object({ | ||
label: zod.string().min(1), | ||
href: zod.string().min(1), | ||
kind: zod.string().min(1).optional(), | ||
group: zod.string().min(1).optional(), | ||
}); | ||
})), | ||
}; | ||
@@ -28,0 +36,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"private": false, | ||
"version": "2.2.2", | ||
"version": "2.3.0", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
@@ -8,7 +8,7 @@ import templates from './variables/templates' | ||
import type { Variable } from './variables/variable' | ||
import type { Page } from './variables/templates' | ||
import type { Page, ExternalLink } from './variables/templates' | ||
export type { Variable, Page, ExternalLink } | ||
export { templates } | ||
export { magidoc } | ||
export type { Variable, Page } | ||
export { toVariablesFile, UnsupportedVariablesError } |
@@ -10,2 +10,9 @@ import type { ZodType } from 'zod' | ||
export type ExternalLink = { | ||
label: string | ||
href: string | ||
kind?: string | ||
group?: string | ||
} | ||
export default { | ||
@@ -42,4 +49,4 @@ APP_LOGO: createVariable<string>('APP_LOGO', stringConverter()), | ||
zod.object({ | ||
title: zod.string().nonempty(), | ||
content: zod.union([zod.array(type), zod.string().nonempty()]), | ||
title: zod.string().min(1), | ||
content: zod.union([zod.array(type), zod.string().min(1)]), | ||
}), | ||
@@ -50,2 +57,13 @@ ) | ||
), | ||
EXTERNAL_LINKS: createVariable<Array<ExternalLink | undefined>>( | ||
'EXTERNAL_LINKS', | ||
arrayConverter((zod) => { | ||
return zod.object({ | ||
label: zod.string().min(1), | ||
href: zod.string().min(1), | ||
kind: zod.string().min(1).optional(), | ||
group: zod.string().min(1).optional(), | ||
}) | ||
}), | ||
), | ||
} |
@@ -27,2 +27,3 @@ import type { ZodType } from 'zod' | ||
'PAGES', | ||
'EXTERNAL_LINKS', | ||
]) | ||
@@ -105,2 +106,19 @@ }) | ||
}) | ||
test('external links', () => { | ||
testArrayVariable( | ||
variables.templates.EXTERNAL_LINKS, | ||
'EXTERNAL_LINKS', | ||
z | ||
.array( | ||
z.object({ | ||
label: z.string().min(1), | ||
href: z.string().min(1), | ||
kind: z.string().min(1).optional(), | ||
group: z.string().min(1).optional(), | ||
}), | ||
) | ||
.optional(), | ||
) | ||
}) | ||
}) | ||
@@ -107,0 +125,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38262
881