diff --git a/bskyweb/cmd/embedr/snippet.go b/bskyweb/cmd/embedr/snippet.go --- a/bskyweb/cmd/embedr/snippet.go +++ b/bskyweb/cmd/embedr/snippet.go @@ -23,12 +23,18 @@ log.Error("bad post record value", "err", err) return "", err } - const tpl = `
{{ .PostText }}

— {{ .PostAuthor }} {{ .PostIndexedAt }}
` + const tpl = `
{{ .PostText }}

{{ .PostAuthor }} {{ .PostIndexedAt }}
` t, err := template.New("snippet").Parse(tpl) if err != nil { log.Error("template parse error", "err", err) return "", err + } + + sortAt := postView.IndexedAt + createdAt, err := syntax.ParseDatetime(post.CreatedAt) + if nil == err && createdAt.String() < sortAt { + sortAt = createdAt.String() } var lang string @@ -41,8 +47,6 @@ authorName = fmt.Sprintf("%s (@%s)", *postView.Author.DisplayName, postView.Author.Handle) } else { authorName = fmt.Sprintf("@%s", postView.Author.Handle) } - fmt.Println(postView.Uri) - fmt.Println(fmt.Sprintf("%s", postView.Uri)) data := struct { PostURI template.URL PostCID string @@ -50,6 +54,8 @@ PostLang string PostText string PostAuthor string PostIndexedAt string + ProfileURL template.URL + PostURL template.URL WidgetURL template.URL }{ PostURI: template.URL(postView.Uri), @@ -57,7 +63,9 @@ PostCID: postView.Cid, PostLang: lang, PostText: post.Text, PostAuthor: authorName, - PostIndexedAt: postView.IndexedAt, // TODO: createdAt? + PostIndexedAt: sortAt, + ProfileURL: template.URL(fmt.Sprintf("https://bsky.app/profile/%s?ref_src=embed", aturi.Authority())), + PostURL: template.URL(fmt.Sprintf("https://bsky.app/profile/%s/post/%s?ref_src=embed", aturi.Authority(), aturi.RecordKey())), WidgetURL: template.URL("https://embed.bsky.app/static/embed.js"), }