astro-portabletext
Advanced tools
Comparing version 0.9.9 to 0.10.0
@@ -1,2 +0,1 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import type { | ||
@@ -25,3 +24,3 @@ ToolkitListNestMode, | ||
* | ||
* @template Value Portable Text payload | ||
* @typeParam Value - Type of Portable Text payload | ||
*/ | ||
@@ -32,3 +31,3 @@ export interface PortableTextProps< | ||
/** | ||
* Portable Text blocks | ||
* Portable Text payload | ||
*/ | ||
@@ -43,6 +42,7 @@ value: Value | Value[]; | ||
/** | ||
* This function is called when faced with unknown types. | ||
* Function to call when faced with unknown types. | ||
* | ||
* Prints a warning message to the console by default. | ||
* Pass `false` to disable. | ||
* @remarks | ||
* - Prints a warning message to the console by default. | ||
* - Use `false` to disable. | ||
*/ | ||
@@ -52,3 +52,5 @@ onMissingComponent?: MissingComponentHandler | boolean; | ||
/** | ||
* `html` or `direct` | ||
* Value can be `html` or `direct`, defaults to `html` | ||
* | ||
* @see {@link https://portabletext.github.io/toolkit/types/ToolkitListNestMode.html ToolkitListNestMode} | ||
*/ | ||
@@ -67,3 +69,3 @@ listNestingMode?: ToolkitListNestMode; | ||
/** | ||
* Used when a `type` handler isn't found | ||
* Used when a {@link PortableTextComponents.type type} component isn't found | ||
*/ | ||
@@ -76,3 +78,3 @@ unknownType: Component; | ||
/** | ||
* Used when a `block` handler isn't found | ||
* Used when a {@link PortableTextComponents.block block} component isn't found | ||
*/ | ||
@@ -85,3 +87,3 @@ unknownBlock: Component<Block>; | ||
/** | ||
* Used when a `list` handler isn't found | ||
* Used when a {@link PortableTextComponents.list list} component isn't found | ||
*/ | ||
@@ -94,3 +96,3 @@ unknownList: Component<List>; | ||
/** | ||
* Used when a `listItem` handler isn't found | ||
* Used when a {@link PortableTextComponents.listItem listItem} component isn't found | ||
*/ | ||
@@ -103,3 +105,3 @@ unknownListItem: Component<ListItem>; | ||
/** | ||
* Used when a `mark` handler isn't found | ||
* Used when a {@link PortableTextComponents.mark mark} component isn't found | ||
*/ | ||
@@ -121,7 +123,7 @@ unknownMark: Component<Mark<never>>; | ||
* | ||
* @template N Type of Portable Text payload that this component will receive on its `node` property | ||
* @typeParam N - Type of Portable Text payload that this component will receive on its `node` property | ||
*/ | ||
export interface Props<N extends TypedObject> { | ||
/** | ||
* Portable Text node | ||
* Portable Text data for this node | ||
*/ | ||
@@ -137,17 +139,15 @@ node: N; | ||
isInline: boolean; | ||
/** | ||
* Set when `style` is used within an Astro component, should be used when defined. | ||
*/ | ||
class?: string | undefined | null; | ||
} | ||
/** | ||
* Alias to `PortableTextBlock` with `style` set to `normal` | ||
* Alias to {@link https://portabletext.github.io/types/interfaces/PortableTextBlock.html PortableTextBlock} with `style` set to `normal` | ||
* | ||
* @see {@link https://portabletext.github.io/types/interfaces/PortableTextBlock.html} | ||
* | ||
* @example | ||
* ```ts | ||
* --- | ||
* import type { Block, Props as $ } from "astro-portabletext/types"; | ||
* | ||
* export type Props = $<Block>; | ||
* --- | ||
* ``` | ||
*/ | ||
@@ -159,10 +159,12 @@ export interface Block extends PortableTextBlock { | ||
/** | ||
* Alias to `ToolkitPortableTextList` | ||
* Alias to {@link https://portabletext.github.io/toolkit/types/ToolkitPortableTextList.html ToolkitPortableTextList} | ||
* | ||
* @see {@link https://portabletext.github.io/toolkit/modules.html#ToolkitPortableTextList} | ||
* | ||
* @example | ||
* ```ts | ||
* --- | ||
* import type { List, Props as $ } from "astro-portabletext/types"; | ||
* | ||
* export type Props = $<List>; | ||
* --- | ||
* ``` | ||
*/ | ||
@@ -172,10 +174,12 @@ export type List = ToolkitPortableTextList; | ||
/** | ||
* Alias to `ToolkitPortableTextListItem` | ||
* Alias to {@link https://portabletext.github.io/toolkit/interfaces/ToolkitPortableTextListItem.html ToolkitPortableTextListItem} | ||
* | ||
* @see {@link https://portabletext.github.io/toolkit/interfaces/ToolkitPortableTextListItem.html} | ||
* | ||
* @example | ||
* ```ts | ||
* --- | ||
* import type { ListItem, Props as $ } from "astro-portabletext/types"; | ||
* | ||
* export type Props = $<ListItem>; | ||
* --- | ||
* ``` | ||
*/ | ||
@@ -185,8 +189,23 @@ export type ListItem = ToolkitPortableTextListItem; | ||
/** | ||
* @template MarkDef Object defining what the `markDef` property will receive | ||
* Extends {@link https://portabletext.github.io/toolkit/interfaces/ToolkitNestedPortableTextSpan.html ToolkitNestedPortableTextSpan} | ||
* with consisting `markDef` and `markKey` properties | ||
* | ||
* @typeParam MarkDef - Object defining the shape of `markDef` property | ||
* | ||
* @remarks | ||
* Refer to {@link https://github.com/portabletext/toolkit/blob/36c51bd360aa7bc9f8b1f47dbe4a8b6adb4b566a/src/buildMarksTree.ts#L92 buildMarksTree} | ||
* | ||
* @example | ||
* ```ts | ||
* --- | ||
* import type { Mark, Props as $ } from "astro-portabletext/types"; | ||
* | ||
* export type Props = $<Mark<{ msg: string }>>; | ||
* type Greet = { msg: string }; | ||
* | ||
* export type Props = $<Mark<Greet>>; | ||
* | ||
* const { node } = Astro.props; | ||
* // node.markDef.msg is of type `string` | ||
* --- | ||
* ``` | ||
*/ | ||
@@ -201,12 +220,18 @@ export interface Mark< | ||
/** | ||
* Alias to `ToolkitTextNode` | ||
* Alias to {@link https://portabletext.github.io/toolkit/interfaces/ToolkitTextNode.html ToolkitTextNode} | ||
* | ||
* @see {@link https://portabletext.github.io/toolkit/interfaces/ToolkitTextNode.html} | ||
* @example | ||
* ```ts | ||
* --- | ||
* import type { TextNode, Props as $ } from "astro-portabletext/types"; | ||
* | ||
* @example | ||
* import type { TextNode, Props } from "astro-portabletext/types"; | ||
* const props = Astro.props as Props<TextNode>; | ||
* export type Props = $<TextNode>; | ||
* --- | ||
* ``` | ||
*/ | ||
export type TextNode = ToolkitTextNode; | ||
/** | ||
* The shape of the {@link PortableTextProps.onMissingComponent onMissingComponent} function | ||
*/ | ||
export type MissingComponentHandler = ( | ||
@@ -213,0 +238,0 @@ message: string, |
{ | ||
"name": "astro-portabletext", | ||
"version": "0.9.9", | ||
"version": "0.10.0", | ||
"type": "module", | ||
@@ -47,4 +47,7 @@ "description": "Render Portable Text with Astro", | ||
"scripts": { | ||
"check": "astro check --root components" | ||
"check": "astro check --root components", | ||
"clean-docs": "rm -rf docs/interfaces && rm -rf docs/modules", | ||
"copy-to-docs": "mv generated-docs/interfaces ./docs && mv ./generated-docs/modules ./docs/", | ||
"generate-docs": "pnpm clean-docs && typedoc && pnpm copy-to-docs" | ||
} | ||
} |
@@ -23,3 +23,2 @@ <div> | ||
- [Documentation](#documentation) | ||
- [Sanity Projects](#sanity-projects) | ||
- [License](#license) | ||
@@ -105,13 +104,8 @@ | ||
Refer to [docs](docs/README.md) page for advanced usage and examples. | ||
Refer to [docs](docs/README.md) page for advanced usage and examples, including implementation with [Sanity](docs/sanity.md). | ||
| ||
## Sanity Projects | ||
Refer to `astro-portabletext` [Sanity docs](docs/sanity.md) page | ||
| ||
## License | ||
ISC |
Sorry, the diff of this file is not supported yet
26167
329
110