Skip to content

Commit

Permalink
chore: minor logging fix for gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishb committed Nov 18, 2024
1 parent dd1a437 commit 6d7ce54
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hugopage

import (
"errors"
"fmt"
"regexp"
"strings"
Expand All @@ -13,12 +14,14 @@ import (
// the important field to extract is "ids", but others might come in handy
// `size` is legacy from pre-responsive design and should be discarded now
// `link` is probably something to enforce in Hugo figure shortcode,
// for us it's mostly "file" to handle, since "attachment_page" makes no sense for Hugo.
// It is mostly "file" to handle, since "attachment_page" makes no sense for Hugo.
var _GalleryRegEx = regexp.MustCompile(`\[gallery ([^\[\]]*)\]`)

var _idRegEx = regexp.MustCompile(`ids="([^"]+)"`)
var _colsRegEx = regexp.MustCompile(`columns="([^"]+)"`)

var galleryWithNoIDsErr = errors.New("no image IDs found in gallery shortcode")

// TODO: should we handle `order="ASC|DESC"` when `orderby="ID"` ?
// Seems to me that people mostly order pictures in galleries arbitrarily.

Expand Down Expand Up @@ -56,7 +59,7 @@ func galleryReplacementFunction(provider ImageURLProvider, galleryInfo string) (
log.Warn().
Str("galleryInfo", galleryInfo).
Msg("No image IDs found in gallery shortcode")
return "", fmt.Errorf("no image IDs found in gallery shortcode")
return "", galleryWithNoIDsErr
}

idsArray := strings.Split(ids[1], ",")
Expand Down

0 comments on commit 6d7ce54

Please sign in to comment.