Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ghosttohugo/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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{} {
Expand Down
17 changes: 8 additions & 9 deletions ghosttohugo/post_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ghosttohugo

import (
"encoding/json"
"testing"
)

Expand Down Expand Up @@ -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)
Expand Down