Skip to content

Commit

Permalink
improve list support
Browse files Browse the repository at this point in the history
  • Loading branch information
amberpixels committed Dec 20, 2024
1 parent 3e36ad4 commit 85e5ece
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 296 deletions.
68 changes: 3 additions & 65 deletions cmd/pprs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,71 +70,8 @@ func main() {
ExitWithError("Couldn't parse the given file", err)
}

_ = blocks
slog.Debug("Using Notion API with the given token: " + in.NotionAPIToken)

blocks2 := notionapi.Blocks{}
blocks2 = append(blocks2, &notionapi.BulletedListItemBlock{
BasicBlock: notionapi.BasicBlock{
Object: notionapi.ObjectTypeBlock,
Type: notionapi.BlockTypeBulletedListItem,
},
BulletedListItem: notionapi.ListItem{
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Text: &notionapi.Text{Content: "A"},
},
},
Children: notionapi.Blocks{
&notionapi.ToDoBlock{
BasicBlock: notionapi.BasicBlock{
Object: notionapi.ObjectTypeBlock,
Type: notionapi.BlockTypeToDo,
},
ToDo: notionapi.ToDo{
Checked: true,
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Text: &notionapi.Text{Content: "A1"},
},
},
},
},
&notionapi.ToDoBlock{
BasicBlock: notionapi.BasicBlock{
Object: notionapi.ObjectTypeBlock,
Type: notionapi.BlockTypeToDo,
},
ToDo: notionapi.ToDo{
Checked: false,
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Text: &notionapi.Text{Content: "A2"},
},
},
},
},
},
},
})
blocks2 = append(blocks2, &notionapi.BulletedListItemBlock{
BasicBlock: notionapi.BasicBlock{
Object: notionapi.ObjectTypeBlock,
Type: notionapi.BlockTypeBulletedListItem,
},
BulletedListItem: notionapi.ListItem{
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Text: &notionapi.Text{Content: "B"},
},
},
},
})

pageReq := &notionapi.PageCreateRequest{
Parent: notionapi.Parent{
Type: notionapi.ParentTypePageID,
Expand All @@ -143,9 +80,10 @@ func main() {
Properties: props,
Children: blocks,
}
_ = blocks2
_ = blocks

jj, _ := json.Marshal(pageReq)
// TEMPORARY for debugging. TODO: remove when done
jj, _ := json.Marshal(pageReq) //nolint:errcheck
fmt.Println(string(jj))

client := notionapi.NewClient(notionapi.Token(in.NotionAPIToken))
Expand Down
Loading

0 comments on commit 85e5ece

Please sign in to comment.