feat: page content

This commit is contained in:
2026-03-02 22:38:29 +01:00
parent 2491d21963
commit e575f34b34
14 changed files with 120 additions and 149 deletions
+2 -16
View File
@@ -1,10 +1,7 @@
package page
import (
"bytes"
"compress/flate"
"context"
"encoding/base64"
"errors"
"fmt"
"log/slog"
@@ -62,12 +59,12 @@ func (s *Service) getPageHeaders(ctx context.Context, uid string) (page PageHead
slog.Debug("loaded page infos", "cover", coverImage, "content", contentMD)
content, err := s.fs.Read(contentMD.Path())
page.md, err = s.fs.Read(contentMD.Path())
if err != nil {
return
}
title := titleRGX.FindStringSubmatch(string(content))
title := titleRGX.FindStringSubmatch(string(page.md))
if len(title) < 2 {
err = fmt.Errorf("%w: no matches for title", ErrMalFormedInput)
return
@@ -81,14 +78,3 @@ func (s *Service) getPageHeaders(ctx context.Context, uid string) (page PageHead
return
}
func getImageUID(path string) string {
var b bytes.Buffer
// NewWriter with NoDict (nil) creates a raw DEFLATE compressor
zw, _ := flate.NewWriter(&b, flate.BestCompression)
zw.Write([]byte(path))
zw.Close() // Essential to flush the final bits
return base64.RawURLEncoding.EncodeToString(b.Bytes())
}