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 533175a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ $ make build_prod
1. [x] WordPress page author
1. [x] Ability to filter by author(s), useful for [WordPress multi-site](https://www.smashingmagazine.com/2020/01/complete-guide-wordpress-multisite/) migrations
1. [x] Featured images - export featured image associations with pages and posts correctly
1. [x] WordPoress [Post formats](https://developer.wordpress.org/advanced-administration/wordpress/post-formats/)
### Why existing tools don't work
Expand Down
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 533175a

Please sign in to comment.