Skip to content

Commit

Permalink
chore: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishb committed Sep 11, 2024
1 parent dd1a6ef commit 9dc396c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/wp2hugo/internal/hugogenerator/hugopage/hugo_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ var _hugoParallaxBlurLinks = regexp.MustCompile(`{{< parallaxblur.*?src="(.+?)".

func NewPage(provider ImageURLProvider, pageURL url.URL, author string, title string, publishDate *time.Time,
isDraft bool, categories []string, tags []string, footnotes []wpparser.Footnote,
htmlContent string, guid *rss.GUID, featuredImageID *string, postFormat string) (*Page, error) {
metadata, err := getMetadata(provider, pageURL, author, title, publishDate, isDraft, categories, tags, guid, featuredImageID, postFormat)
htmlContent string, guid *rss.GUID, featuredImageID *string, postFormat *string) (*Page, error) {
metadata, err := getMetadata(provider, pageURL, author, title, publishDate, isDraft, categories, tags, guid,
featuredImageID, postFormat)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -119,7 +120,8 @@ func getMarkdownLinks(regex *regexp.Regexp, markdown string) []string {
}

func getMetadata(provider ImageURLProvider, pageURL url.URL, author string, title string, publishDate *time.Time,
isDraft bool, categories []string, tags []string, guid *rss.GUID, featuredImageID *string, postFormat string) (map[string]any, error) {
isDraft bool, categories []string, tags []string, guid *rss.GUID, featuredImageID *string,
postFormat *string) (map[string]any, error) {
metadata := make(map[string]any)
metadata["url"] = pageURL.Path // Relative URL
metadata["author"] = author
Expand Down Expand Up @@ -163,8 +165,8 @@ func getMetadata(provider ImageURLProvider, pageURL url.URL, author string, titl
metadata["cover"] = coverInfo
}
}
if postFormat != "" {
metadata["type"] = postFormat
if postFormat != nil {
metadata["type"] = *postFormat
}
return metadata, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestManualLineBreaks(t *testing.T) {
func testMarkdownExtractor(t *testing.T, htmlInput string, markdownOutput string) {
url1, err := url.Parse("https://example.com")
assert.Nil(t, err)
page, err := NewPage(nil, *url1, "author", "Title", nil, false, nil, nil, nil, htmlInput, nil, nil)
page, err := NewPage(nil, *url1, "author", "Title", nil, false, nil, nil, nil, htmlInput, nil, nil, nil)
assert.Nil(t, err)
md, err := page.getMarkdown(nil, htmlInput, nil)
assert.Nil(t, err)
Expand Down
7 changes: 4 additions & 3 deletions src/wp2hugo/internal/wpparser/wp_parser_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type CommonFields struct {
LastModifiedDate *time.Time
PublishStatus PublishStatus // "publish", "draft", "pending" etc. may be make this a custom type
GUID *rss.GUID
PostFormat string
PostFormat *string

Description string // how to use this?
Content string
Expand Down Expand Up @@ -309,15 +309,16 @@ func getCommonFields(item *rss.Item) (*CommonFields, error) {
}
pageCategories := make([]string, 0, len(item.Categories))
pageTags := make([]string, 0, len(item.Categories))
var postFormat string
var postFormat *string

for _, category := range item.Categories {
if isCategory(category) {
pageCategories = append(pageTags, NormalizeCategoryName(category.Value))
} else if isTag(category) {
pageTags = append(pageTags, NormalizeCategoryName(category.Value))
} else if isPostFormat(category) {
postFormat = NormalizeCategoryName(category.Value)
tmp := NormalizeCategoryName(category.Value)
postFormat = &tmp
} else {
log.Warn().
Str("link", item.Link).
Expand Down

0 comments on commit 9dc396c

Please sign in to comment.