v1.0.0-beta.26
🚀 Features and🚨 Breaking Changes
For variants, what used to be:
import type { Variant, Viewports } from 'kitbook'
import type Component from './Foo.svelte'
export const viewports: Viewports[] = [
{ width: 500, height: 200 }
]
export const variants: Variant<Component>[] = [
{
name: 'First',
props: {
foo: 'a',
}
},
{
name: 'Second',
description: 'This is the second variant.',
props: {
foo: 'b',
},
},
]
Is now:
import type { Variant, VariantMeta } from 'kitbook'
import type Component from './Foo.svelte'
export const shared_meta: VariantMeta = {
viewports: [
{ width: 500, height: 200 }
]
}
export const First: Variant<Component> = {
foo: 'a',
}
export const Second: Variant<Component> = {
foo: 'b',
_meta: {
description: 'This is the second variant.',
},
}
As you are able, update to the new api which only exports the optional shared_meta
property plus the variants themselves. Kitbook will still accept the deprecated variants array api, but the types will throw errors. As you are transitioning, for the moment you can just find-replace all the Variant
types to be DeprecatedVariant
.
A quick tip to upgrade is to delete your variants.ts
file and then create a new one using Kitbook's Add Variant
button. Then use VS Code's version control to paste from your old file into the new. Alternatively, you can ask an LLM to help you. I've added a one-shot prompt to help out with that.
Compositions also still work with the old api, but moving forward config should be defined in this manner to get intellisense and prepare for removal of the deprecation in a future version:
<script context="module" lang="ts">
import { defineComposition } from 'kitbook'
export const config = defineComposition({
viewports: [{ height: 50 }],
})
</script>
Full Changelog: v1.0.0-beta.24...v1.0.0-beta.26