Skip to content

Commit 0f6ebe5

Browse files
committed
fix: notion error when target url is empty
1 parent b560503 commit 0f6ebe5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

impl/notion/operator.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ func (o *Archiver) Operate(item *cubox.Item) error {
2323
}
2424

2525
func (o *Archiver) createNewPage(item *cubox.Item) (*notionapi.Page, error) {
26+
nameText := notionapi.RichText{
27+
Text: &notionapi.Text{Content: item.Title},
28+
}
29+
if item.TargetURL != "" {
30+
nameText.Text.Link = &notionapi.Link{Url: item.TargetURL}
31+
}
2632
properties := map[string]notionapi.Property{
2733
// todo 把这里的属性名换成常量,在创建数据库的时候也要用到
2834
"Name": notionapi.TitleProperty{
29-
Title: []notionapi.RichText{
30-
{
31-
Text: &notionapi.Text{Content: item.Title, Link: &notionapi.Link{Url: item.TargetURL}},
32-
},
33-
},
35+
Title: []notionapi.RichText{nameText},
3436
},
3537
"CuboxID": notionapi.RichTextProperty{
3638
RichText: []notionapi.RichText{

0 commit comments

Comments
 (0)