add page for single micro-blog posts

", p.ID, p.Source, p.ID))
posted: %s
", p.Timestamp.Format("2006-01-02 15:04")))

")

", post.Title))

",

")

---

")
")
")

", post.Title))
")
")
This commit is contained in:
Travis Shears 2025-10-18 21:17:34 +02:00
parent a88994add4
commit d6d00f6dc9
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
3 changed files with 76 additions and 25 deletions

View file

@ -195,3 +195,33 @@ func (c *PocketBaseClient) GetList(
}
return &res, nil
}
func (c *PocketBaseClient) GetRecord(
collection string,
id string,
) (*[]byte, error) {
slog.Info(
"Getting single record from pocketbase",
"recordId", id)
apiURL := fmt.Sprintf("%s/api/collections/%s/records/%s", c.host, collection, id)
resp, err := c.makeAuthenticatedRequest("GET", apiURL, nil)
if err != nil {
return nil, fmt.Errorf("failed to make request: %w", err)
}
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("API request failed with status %d: %s", resp.StatusCode, string(body))
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
defer resp.Body.Close()
var res pbRes
if err := json.Unmarshal(body, &res); err != nil {
return nil, fmt.Errorf("failed to decode response: %w", err)
}
return &body, nil
}