Skip to content

Commit

Permalink
fix: handle empty tag names
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishb committed Jul 28, 2024
1 parent cb39865 commit 0af0710
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/wp2hugo/internal/wpparser/wp_parser_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,20 @@ func getCategories(inputs []ext.Extension) []CategoryInfo {
func getTags(inputs []ext.Extension) []TagInfo {
categories := make([]TagInfo, 0, len(inputs))
for _, input := range inputs {
var tagName string
if len(input.Children["tag_name"]) == 0 {
// Fallback
tagName = input.Children["tag_slug"][0].Value
log.Warn().
Any("input", input).
Msg("tag_name is missing")
} else {
tagName = input.Children["tag_name"][0].Value
}
tag := TagInfo{
// ID is usually int but for safety let's assume string
ID: input.Children["term_id"][0].Value,
Name: NormalizeCategoryName(input.Children["tag_name"][0].Value),
Name: NormalizeCategoryName(tagName),
Slug: input.Children["tag_slug"][0].Value,
}
log.Trace().Msgf("tag: %+v", tag)
Expand Down

0 comments on commit 0af0710

Please sign in to comment.