summaryrefslogtreecommitdiff
path: root/internal/post
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-27 08:38:37 +0300
committerPaul Buetow <paul@buetow.org>2026-04-27 08:38:37 +0300
commit9ce439a217a8f2f5c48317bb5fb37e65d2f11ede (patch)
tree3f78dd10da3bb41b2613a5d73653165c9bd17324 /internal/post
parent8defd48636eeebb3916809fc3f21c2e3d7c9ef5b (diff)
Move post.Load constructor before methods in post.go
Diffstat (limited to 'internal/post')
-rw-r--r--internal/post/post.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/internal/post/post.go b/internal/post/post.go
index cdef546..38dff03 100644
--- a/internal/post/post.go
+++ b/internal/post/post.go
@@ -40,21 +40,6 @@ type Post struct {
Assets []string `json:"assets,omitempty"`
}
-// Save writes the post as post.json into dir.
-func (p *Post) Save(dir string) error {
- data, err := json.MarshalIndent(p, "", " ")
- if err != nil {
- return fmt.Errorf("marshal post %s: %w", p.ID, err)
- }
-
- path := filepath.Join(dir, "post.json")
- if err := os.WriteFile(path, data, 0o644); err != nil {
- return fmt.Errorf("write post.json for %s: %w", p.ID, err)
- }
-
- return nil
-}
-
// Load reads and parses post.json from dir.
func Load(dir string) (*Post, error) {
path := filepath.Join(dir, "post.json")
@@ -82,3 +67,18 @@ func NewID(t time.Time, suffix int) string {
return fmt.Sprintf("%s-%d", base, suffix)
}
+
+// Save writes the post as post.json into dir.
+func (p *Post) Save(dir string) error {
+ data, err := json.MarshalIndent(p, "", " ")
+ if err != nil {
+ return fmt.Errorf("marshal post %s: %w", p.ID, err)
+ }
+
+ path := filepath.Join(dir, "post.json")
+ if err := os.WriteFile(path, data, 0o644); err != nil {
+ return fmt.Errorf("write post.json for %s: %w", p.ID, err)
+ }
+
+ return nil
+}