diff options
| author | 2025-10-17 04:17:06 +0700 | |
|---|---|---|
| committer | 2025-10-17 04:17:06 +0700 | |
| commit | c9a2858279d3d3bf48d752d5ad250303368f9ebd (patch) | |
| tree | 9756d29796f30156a071920fef3f9cb15dffa1a6 /internal/glightbox/parser.go | |
| parent | b3a60ae640c3a69f1b2767877c6b4975d62e539c (diff) | |
| download | web-c9a2858279d3d3bf48d752d5ad250303368f9ebd.tar.gz web-c9a2858279d3d3bf48d752d5ad250303368f9ebd.zip | |
feat: add support for tags in gallery images
feat: add 2x tag for an image in gallery
feat: update layout of galleries while loading images (not just after)
Diffstat (limited to 'internal/glightbox/parser.go')
| -rw-r--r-- | internal/glightbox/parser.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/internal/glightbox/parser.go b/internal/glightbox/parser.go index ba3f22e..6780090 100644 --- a/internal/glightbox/parser.go +++ b/internal/glightbox/parser.go @@ -4,6 +4,7 @@ import ( "bytes" "log/slog" "regexp" + "strings" "time" "github.com/yuin/goldmark/ast" @@ -60,16 +61,27 @@ func (p *GLightboxParser) Continue(node ast.Node, reader text.Reader, pc parser. gallery := node.(*GLightboxBlock) - parts := bytes.SplitN(trimmed, []byte{'|'}, 2) + parts := bytes.SplitN(trimmed, []byte{'|'}, 3) url := bytes.TrimSpace(parts[0]) caption := make([]byte, 0) - if len(parts) > 1 { + tagsRaw := "" + if len(parts) == 2 { caption = bytes.TrimSpace(parts[1]) } + if len(parts) >= 3 { + tagsRaw = string(parts[1]) + caption = bytes.TrimSpace(parts[2]) + } + + tags := strings.Split(tagsRaw, ",") + for i := range tags { + tags[i] = strings.TrimSpace(tags[i]) + } gallery.Images = append(gallery.Images, GLightboxImage{ URL: string(url), + Tags: tags, Caption: caption, }) |