package portabletext
import "github.com/bep/goportabletext/internal/portabletext"
Index ¶
- type Asset
- type BaseBlock
- type Block
- type Blocks
- type Child
- type Code
- type Image
- type MarkDef
- type Style
- type Text
- type Type
Types ¶
type Asset ¶
type Asset struct { ID string `json:"_id" mapstructure:"_id"` AltText string `json:"altText" mapstructure:"altText"` Description string `json:"description" mapstructure:"description"` Metadata struct { Dimensions struct { AspectRatio float64 `json:"aspectRatio" mapstructure:"aspectRatio"` Height int `json:"height" mapstructure:"height"` Width int `json:"width" mapstructure:"width"` } `json:"dimensions"` } `json:"metadata"` Path string `json:"path" mapstructure:"path"` Title string `json:"title" mapstructure:"title"` URL string `json:"url" mapstructure:"url"` }
type BaseBlock ¶
type BaseBlock struct { // Key is a unique identifier for the block. Key string `json:"_key" mapstructure:"_key"` // The type makes it possible for a serializer to parse the contents of the block. Type Type `json:"_type" mapstructure:"_type"` }
type Block ¶
type Block struct { BaseBlock `mapstructure:",squash"` // Union type. // A block can be either a text block or an image block. // The type field is used to determine which type of block it is. Text `mapstructure:",squash"` Image `mapstructure:",squash"` Code `mapstructure:",squash"` }
A Block is a top-level structure in a Portable Text array.
func (Block) HasText ¶
type Blocks ¶
type Blocks []Block
func Parse ¶
The Parse function reads a Portable Text block or array from the src. The src aan be either a io.Reader or a ... TODO1
type Child ¶
type Child struct { // The type makes it possible for a serializer to parse the contents of the block. Type Type `json:"_type" mapstructure:"_type"` // Marks are how we mark up inline text with additional data/features. // Marks comes in two forms: Decorators and Annotations. // Decorators are marks as simple string values, while Annotations are keys to a data structure. // marks is therefore either an array of string values, or keys, corresponding to markDefs, with the same _key. Marks []string `json:"marks" mapstructure:"marks"` // The text contents of the span. Text string `json:"text" mapstructure:"text"` }
A Child is a span or custom inline type that is contained within a block. A span is the standard way to express inline text within a block
type Code ¶
type Code struct { Code string `json:"code" mapstructure:"code"` Filename string `json:"filename" mapstructure:"filename"` Language string `json:"language" mapstructure:"language"` }
type Image ¶
type Image struct { Asset Asset `json:"asset" mapstructure:"asset"` }
type MarkDef ¶
type MarkDef struct { Key string `json:"_key" mapstructure:"_key"` Type Type `json:"_type" mapstructure:"_type"` Href string `json:"href" mapstructure:"href"` }
type Style ¶
type Style string
type Text ¶
type Text struct { // Children is an array of spans or custom inline types that is contained within a block. Children []Child `json:"children" mapstructure:"children"` // MarkDefs definitions is an array of objects with a key, type and some data. // Mark definitions are tied to spans by adding the referring _key in the marks array. MarkDefs []MarkDef `json:"markDefs" mapstructure:"markDefs"` // Style typically describes a visual property for the whole block. Style Style `json:"style,omitempty" mapstructure:"style"` // Level is used to express visual nesting and hierarchical structures between blocks in the array. Level int `json:"level,omitempty" mapstructure:"level"` // A block can be given the property listItem with a value that describes which kind of list it is. // Typically bullet, number, square and so on. // The list position is derived from the position the block has in the array and surrounding list items on the same level. ListItem string `json:"listItem,omitempty" mapstructure:"listItem"` }
type Type ¶
type Type string
Source Files ¶
- Version
- v0.1.0 (latest)
- Published
- Feb 25, 2025
- Platform
- js/wasm
- Imports
- 6 packages
- Last checked
- 1 month ago –
Tools for package owners.