Skip to content

Commit

Permalink
feat: add a second arg to image, 'link', which put a link to the entr…
Browse files Browse the repository at this point in the history
…y associated with the image.
  • Loading branch information
slurdge committed Mar 16, 2023
1 parent 2c24d5c commit eef64c6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/goeland/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,20 @@ func filterEmbedImage(source *goeland.Source, params *filterParams) {
}
}
}
includeEntryLink := false
if len(args) > 1 {
if strings.ToLower(args[1]) == "link" {
includeEntryLink = true
}
}
for i, entry := range source.Entries {
if strings.TrimSpace(entry.ImageURL) == "" {
continue
}
imageLink := fmt.Sprintf(`<img src="%s" class="%s">`, entry.ImageURL, positions[position])
if includeEntryLink {
imageLink = fmt.Sprintf(`<a href="%s">%s</a>`, entry.URL, imageLink)
}
switch position {
case 0:
entry.Content = imageLink + entry.Content
Expand Down

0 comments on commit eef64c6

Please sign in to comment.