modularizing opengraph headers and fixing a bunch of small things on there.

This commit is contained in:
fiatjaf
2023-11-06 11:07:20 -03:00
parent f349bd2d1d
commit 604be14407
7 changed files with 103 additions and 90 deletions

View File

@@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
html "html"
"html"
"html/template"
"io"
"net/http"
@@ -549,3 +549,15 @@ func limitAt[V any](list []V, n int) []V {
}
return list[0:n]
}
func humanDate(createdAt nostr.Timestamp) string {
ts := createdAt.Time()
now := time.Now()
if ts.Before(now.AddDate(0, -9, 0)) {
return ts.UTC().Format("02 Jan 2006")
} else if ts.Before(now.AddDate(0, 0, -6)) {
return ts.UTC().Format("Jan _2")
} else {
return ts.UTC().Format("Mon, Jan _2 15:04 UTC")
}
}