Skip to content

Commit

Permalink
blog: fix slugs for Mataroa
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Aug 15, 2024
1 parent 3d10c46 commit b86d7f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func getAndValidateSlug(mdFilename, title string) (string, error) {
// 01-my-awesome-blog-post.md => my-awesome-blog-post
filenameSlug := strings.TrimSuffix(mdFilename[3:], ".md")
// My awesome blog post => my-awesome-blog-post
titleSlug := slug.Make(title)
titleSlug := getSlug(title)

// Add any filename that are known to be broken, generally because the
// title got changed after publishing
Expand All @@ -126,6 +126,15 @@ func getAndValidateSlug(mdFilename, title string) (string, error) {
return filenameSlug, nil
}

func getSlug(s string) string {
// Mataroa slug function removes any "." from the slug
slug.CustomSub = map[string]string{
".": "",
}
return slug.Make(s)

}

func grabPosts() posts {
posts := orderedmap.NewOrderedMap[string, post]()

Expand Down Expand Up @@ -255,7 +264,7 @@ func main() {
flag.Parse()

if *slugify != "" {
fmt.Println(slug.Make(*slugify))
fmt.Println(getSlug(*slugify))
os.Exit(0)
}

Expand Down

0 comments on commit b86d7f3

Please sign in to comment.