commit a47cefa
Artur Manuel
·
2026-05-21 01:18:31 +0000 UTC
parent dbf4d29
meta: reformat with make lint
3 files changed,
+38,
-38
+6,
-6
1@@ -63,15 +63,15 @@ func mainAction(ctx context.Context, c *cli.Command) error {
2 }
3 sidebar, err := ssg.GetSidebar(pagesDir)
4 if err != nil {
5- return err
6+ return err
7 }
8 outputDir := c.String("output-dir")
9 if err := os.MkdirAll(outputDir, 0o700); os.IsNotExist(err) {
10 return err
11 }
12- if err := ssg.FromAssets("./assets", outputDir); err != nil {
13- return err
14- }
15+ if err := ssg.FromAssets("./assets", outputDir); err != nil {
16+ return err
17+ }
18 markdown := goldmark.New(
19 goldmark.WithExtensions(meta.Meta),
20 goldmark.WithParserOptions(parser.WithAutoHeadingID()),
21@@ -85,7 +85,7 @@ func mainAction(ctx context.Context, c *cli.Command) error {
22 return err
23 }
24 if err := ssg.BuildPage(f, name, path, page, markdown, templates, config, baseUrl, sidebar); err != nil {
25- return err
26+ return err
27 }
28 }
29 return nil
30@@ -96,4 +96,4 @@ func main() {
31 slog.Error("got err while generating pages", "err", err)
32 os.Exit(1)
33 }
34-}
35+}
+29,
-29
1@@ -1,36 +1,36 @@
2 package ssg
3
4 import (
5- "io"
6- "io/fs"
7- "log/slog"
8- "os"
9- "path/filepath"
10+ "io"
11+ "io/fs"
12+ "log/slog"
13+ "os"
14+ "path/filepath"
15 )
16
17 // i couldn't come up with a better name for the function without it being too verbose but bwaaa who cares ig ;w;
18 func FromAssets(assetsDir string, outputDir string) error {
19- err := filepath.WalkDir(assetsDir, func(path string, d fs.DirEntry, err error) error {
20- if err != nil {
21- slog.Error("got err while reading path", "path", path, "err", err) // those who error :skull:
22- return filepath.SkipDir
23- }
24- if d.IsDir() {
25- return nil
26- }
27- destPath := filepath.Join(outputDir, filepath.Base(path))
28- src, err := os.Open(path)
29- if err != nil {
30- return err
31- }
32- defer src.Close()
33- dst, err := os.Create(destPath)
34- if err != nil {
35- return err
36- }
37- defer dst.Close()
38- _, err = io.Copy(dst, src)
39- return err
40- })
41- return err
42-}
43+ err := filepath.WalkDir(assetsDir, func(path string, d fs.DirEntry, err error) error {
44+ if err != nil {
45+ slog.Error("got err while reading path", "path", path, "err", err) // those who error :skull:
46+ return filepath.SkipDir
47+ }
48+ if d.IsDir() {
49+ return nil
50+ }
51+ destPath := filepath.Join(outputDir, filepath.Base(path))
52+ src, err := os.Open(path)
53+ if err != nil {
54+ return err
55+ }
56+ defer src.Close()
57+ dst, err := os.Create(destPath)
58+ if err != nil {
59+ return err
60+ }
61+ defer dst.Close()
62+ _, err = io.Copy(dst, src)
63+ return err
64+ })
65+ return err
66+}
+3,
-3
1@@ -15,12 +15,12 @@ type TemplateData struct {
2 Params map[string]any
3 Config Config
4 Content string
5- Sidebar []SidebarItem
6+ Sidebar []SidebarItem
7 }
8
9 type SidebarItem struct {
10- Name string
11- Path string
12+ Name string
13+ Path string
14 }
15
16 type Templates map[string]string