diff --git a/ghosttohugo/post.go b/ghosttohugo/post.go index 7072c9b..380b915 100644 --- a/ghosttohugo/post.go +++ b/ghosttohugo/post.go @@ -22,7 +22,7 @@ type post struct { MobileDoc string `json:"mobiledoc,omitempty"` Image string `json:"image"` FeaturedImage string `json:"feature_image,omitempty"` - Page json.RawMessage `json:"page"` + Type string `json:"type"` Status string `json:"status"` MetaDescription string `json:"meta_description"` AuthorID json.RawMessage `json:"author_id"` @@ -41,7 +41,7 @@ func (p post) isDraft() bool { } func (p post) isPage() bool { - return parseBool(p.Page) + return strings.ToLower(p.Type) == "page" } func (p post) frontMatter() map[string]interface{} { diff --git a/ghosttohugo/post_test.go b/ghosttohugo/post_test.go index 4a23bb2..b7552ca 100644 --- a/ghosttohugo/post_test.go +++ b/ghosttohugo/post_test.go @@ -1,7 +1,6 @@ package ghosttohugo import ( - "encoding/json" "testing" ) @@ -29,20 +28,20 @@ func Test_post_isDraft(t *testing.T) { func Test_post_isPage(t *testing.T) { tests := []struct { name string - page json.RawMessage + Type string want bool }{ - {"nil", json.RawMessage(nil), false}, - {"empty", json.RawMessage([]byte{}), false}, - {"true", json.RawMessage([]byte("true")), true}, - {"false", json.RawMessage([]byte("false")), false}, - {"true_int", json.RawMessage([]byte{49}), true}, - {"false_int", json.RawMessage([]byte{0}), false}, + {"nil", "", false}, + {"empty", "", false}, + {"true", "page", true}, + {"false", "false", false}, + {"true_int", "1", false}, + {"false_int", "0", false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { p := post{ - Page: tt.page, + Type: tt.Type, } if got := p.isPage(); got != tt.want { t.Errorf("post.isPage() = %v, want %v", got, tt.want)