summaryrefslogtreecommitdiff
path: root/internal/b2/client.go
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'internal/b2/client.go')
-rw-r--r--internal/b2/client.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/internal/b2/client.go b/internal/b2/client.go
index 5322b84..fda79e0 100644
--- a/internal/b2/client.go
+++ b/internal/b2/client.go
@@ -3,6 +3,7 @@ package b2
import (
"context"
"fmt"
+ "slices"
"strings"
"time"
@@ -32,9 +33,11 @@ func NewB2Client(cfg *config.B2Config) (*B2Client, error) {
}
type BlogPage struct {
- Link string
- FileName string
- Metadata *frontmatter.Metadata
+ Link string
+ FileName string
+ Lang string
+ ModifiedTime time.Time
+ Metadata *frontmatter.Metadata
}
func (c *B2Client) Scan(prefix string) ([]*BlogPage, error) {
@@ -74,16 +77,24 @@ func (c *B2Client) Scan(prefix string) ([]*BlogPage, error) {
nameParts := strings.Split(linkParts[len(linkParts)-1], ".")
fileName := strings.Join(nameParts[:len(linkParts)-1], ".")
+ tags := strings.Split(attrs.Info["tags"], ",")
+ slices.Sort(tags)
+
+ lang, _ := strings.CutPrefix(linkParts[0], c.prefix)
+
filePaths = append(filePaths, &BlogPage{
- Link: obj.Name(),
- FileName: fileName,
+ Link: obj.Name(),
+ FileName: fileName,
+ Lang: lang,
+ ModifiedTime: attrs.LastModified,
Metadata: &frontmatter.Metadata{
Title: attrs.Info["title"],
ShortDescription: attrs.Info["short-description"],
ActionDate: attrs.Info["action-date"],
PublishedTime: publishedTime,
Thumbnail: attrs.Info["thumbnail"],
- Tags: strings.Split(attrs.Info["tags"], ","),
+ Tags: tags,
+ Geolocation: attrs.Info["geolocation"],
},
})
}