this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

use sanitized leaflet title as filename

Signed-off-by: Marius Kimmina <mar.kimmina@gmail.com>

+12 -2
+12 -2
cmd/leaflet-hugo-sync/main.go
··· 20 20 return parts[len(parts)-1] 21 21 } 22 22 23 + func sanitizeTitle(title string) string { 24 + // Replace spaces with underscores and remove/replace unsafe characters 25 + s := strings.ReplaceAll(title, " ", "_") 26 + s = strings.ReplaceAll(s, "/", "_") 27 + s = strings.ReplaceAll(s, "\\", "_") 28 + s = strings.ReplaceAll(s, ":", "_") 29 + return s 30 + } 31 + 23 32 func main() { 24 33 configPath := flag.String("config", ".leaflet-sync.yaml", "Path to config file") 25 34 flag.Parse() ··· 141 150 finalContent = strings.ReplaceAll(finalContent, imgRef.Blob.Ref.Link, localPath) 142 151 } 143 152 144 - // Slug generation 153 + // Generate filename from title and slug from URI 145 154 slug := lastPathPart(rec.Uri) 155 + filename := sanitizeTitle(doc.Title) 146 156 147 157 // Construct original URL 148 158 originalURL := fmt.Sprintf("https://leaflet.pub/%s", slug) ··· 150 160 postData := generator.PostData{ 151 161 Title: doc.Title, 152 162 CreatedAt: doc.PublishedAt, 153 - Slug: slug, 163 + Slug: filename, 154 164 Handle: cfg.Source.Handle, 155 165 OriginalURL: originalURL, 156 166 Content: finalContent,