notionopt

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockTypeUnsportected = errors.New("unsportected block type")
	ErrConvertDOTFailed      = errors.New("convert to notion.BlockDTO failed")
	ErrRichtextIsNull        = errors.New("the text is null")
)

Functions

func ConvertImageBlock

func ConvertImageBlock(blockDTO *notion.BlockDTO) notion.Block

ConvertImageBlock convert image block to richtext link.

func GetBlockContent

func GetBlockContent(block notion.Block) (string, error)

Get string block content

func GetFullRichtext

func GetFullRichtext(richText []notion.RichText) string

GetFullRickText Merging all richtext into a single string. May cause loss of some formatting properties, such as color attributes.

func GetRichtext

func GetRichtext(block notion.Block) (*[]notion.RichText, error)

func IsSupported

func IsSupported(dto *notion.BlockDTO) bool

Supported block types

func MergeChildBlocks

func MergeChildBlocks(content1, content2 string) (merged string, err error)

MergeChildBlocks merge the content into a single JSON string content format is notion.BlockChildrenResponse

func ReplaceBlockContent

func ReplaceBlockContent(block notion.Block, newContent string) error

Replace block content by a new string content. May cause loss of some formatting properties, such as color attributes.

func ReplaceRichtext

func ReplaceRichtext(richtext *[]notion.RichText, newContent string) error

Types

type INotionOperator

type INotionOperator interface {
	// Fetch notion content for a given page.
	// !MUST support recursive
	// @Pararm uuid,
	// @Return string content
	FetchPage(uuid string) (content string, err error)

	// Upload content to notion
	// @Pararm parentId, uuid of parent page
	// @Pararm content, json format page content
	// @Return uuid, new page's uuid
	UploadPage(parentId string, page *NotionPage) (uuid string, err error)

	// Content2NotionPage converting string content to NotionPage struct
	// @Pararm srcContent, JSON string page content
	// @Return *NotionPage, converted page
	Content2NotionPage(srcContent string) (*NotionPage, error)
}

INotionOperator. Get Notion page content, support for recursion. Object serialization.

type NotionOperator

type NotionOperator struct {
	// contains filtered or unexported fields
}

NotionOperator Implementation of INotionOperator Not considering concurrency

func CreateNotionOperator

func CreateNotionOperator(auth string) *NotionOperator

CreateNotionOperator

func (*NotionOperator) AppendBlockChildren

func (n *NotionOperator) AppendBlockChildren(parentId string, block notion.Block) error

func (*NotionOperator) Content2NotionPage

func (n *NotionOperator) Content2NotionPage(srcContent string) (*NotionPage, error)

Content2NotionPage converting string content to NotionPage struct

func (*NotionOperator) CreateNewPage

func (n *NotionOperator) CreateNewPage(parentId string, page *NotionPage) (uuid string, err error)

func (*NotionOperator) FetchPage

func (n *NotionOperator) FetchPage(uuid string) (content string, err error)

Fetch page from notion @Pararm uuid, page uuid @Return txId, txId return by Arweave

func (*NotionOperator) UploadPage

func (n *NotionOperator) UploadPage(parentId string, page *NotionPage) (uuid string, err error)

UploadPage uploading page content to notion @Pararm parentId, parent page uuid, where new page to be loaded @Pararm page, page content @Return uuid, uuid of new page

type NotionPage

type NotionPage struct {
	PageInfo    notion.Page                  `json:"page_info"`
	PageContent notion.BlockChildrenResponse `json:"page_content"`
}

notion page

func Content2NotionPage

func Content2NotionPage(srcContent string) (*NotionPage, error)

content2NotionPage converting string content to NotionPage struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL